element-x-ada/tools/detekt/detekt.yml
Jorge Martin Espinosa adc61b3826
Add media file limit size warning and media quality selection (#5131)
* Add `VideoCompressorPreset` enum

This represents the different compression presets used for processing videos before uploading them

* Add `VideoCompressorHelper` util class to calculate the scaled output size of the video given an input size and its optimal bitrate

Also add `MediaOptimizationConfig` which will be used to decide how to apply compression in `MediaPreProcessor`

* Add `RustMatrixClient.getMaxFileUploadSize()` function and `MaxUploadSizeProvider` so we can import only this functionality into other components

* Try preloading the max file upload size the first time we get network connectivity - it's a best effort

This should help ensure we'll have this value available later, even if we still need to load it asynchronously.

* Split the `compressMedia` preference into `compressImages` and `compressMediaPreset`

* Modify the media processing parts to use the new classes and utils

* Add `MediaOptimizationSelectorPresenter`, which will retrieve the compression values and the max file upload size, also estimating the compressed video file sizes if needed.

* Add a feature flag to allow selecting the media upload quality per upload

* Integrate the previous changes with the attachments preview screen

Add strings from localazy too.

* Adapt the rest of the app calls to upload media to using the media optimization configs

* Allow modifying the default compression values in advanced settings, based on the feature flag value

* Pass the `fileSize` in `MediaUploadInfo` too, to be able to check it against the `maxUploadSize`

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2025-08-11 17:22:46 +02:00

270 lines
6.2 KiB
YAML

# Default rules: https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml
style:
AlsoCouldBeApply:
active: true
BracesOnWhenStatements:
active: false
CascadingCallWrapping:
active: true
includeElvis: true
DataClassShouldBeImmutable:
active: true
EqualsNullCall:
active: true
EqualsOnSignatureLine:
active: true
ExplicitCollectionElementAccessMethod:
active: true
ExplicitItLambdaParameter:
active: true
MaxLineLength:
# Default is 120
maxLineLength: 160
MagicNumber:
active: false
ReturnCount:
active: false
UnnecessaryAbstractClass:
active: true
FunctionOnlyReturningConstant:
active: false
UnusedPrivateMember:
active: true
DestructuringDeclarationWithTooManyEntries:
active: true
maxDestructuringEntries: 5
UnusedParameter:
active: true
UnnecessaryInnerClass:
active: true
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
allowForUnclearPrecedence: false
UntilInsteadOfRangeTo:
active: true
UnusedImports:
active: true
UnusedPrivateProperty:
active: true
ThrowsCount:
active: false
LoopWithTooManyJumpStatements:
active: true
SerialVersionUIDInSerializableClass:
active: false
ProtectedMemberInFinalClass:
active: true
UseCheckOrError:
active: true
OptionalUnit:
active: true
PreferToOverPairSyntax:
active: true
RedundantExplicitType:
active: true
TrailingWhitespace:
active: true
TrimMultilineRawString:
active: true
trimmingMethods:
- 'trimIndent'
- 'trimMargin'
UnderscoresInNumericLiterals:
active: true
acceptableLength: 4
allowNonStandardGrouping: false
UnnecessaryAnnotationUseSiteTarget:
active: true
UnnecessaryBackticks:
active: true
UnnecessaryBracesAroundTrailingLambda:
active: true
UseDataClass:
active: true
allowVars: false
UseEmptyCounterpart:
active: true
UseIfEmptyOrIfBlank:
active: true
UseLet:
active: true
UseSumOfInsteadOfFlatMapSize:
active: true
coroutines:
GlobalCoroutineUsage:
# Keep false for now.
active: false
SuspendFunSwallowedCancellation:
active: true
SuspendFunWithCoroutineScopeReceiver:
active: true
empty-blocks:
EmptyFunctionBlock:
active: false
EmptySecondaryConstructor:
active: true
potential-bugs:
ImplicitDefaultLocale:
active: true
CastNullableToNonNullableType:
active: true
CastToNullableType:
active: true
Deprecation:
active: true
DontDowncastCollectionTypes:
active: true
ElseCaseInsteadOfExhaustiveWhen:
active: true
ExitOutsideMain:
active: true
ImplicitUnitReturnType:
active: true
allowExplicitReturnType: false
MissingPackageDeclaration:
active: true
excludes: [ '**/*.kts' ]
NullCheckOnMutableProperty:
active: true
NullableToStringCall:
active: true
PropertyUsedBeforeDeclaration:
active: true
UnconditionalJumpStatementInLoop:
active: true
UnnecessaryNotNullCheck:
active: true
exceptions:
TooGenericExceptionCaught:
active: false
SwallowedException:
active: false
ThrowingExceptionsWithoutMessageOrCause:
active: true
TooGenericExceptionThrown:
active: true
InstanceOfCheckForException:
active: true
ObjectExtendsThrowable:
active: true
complexity:
TooManyFunctions:
active: false
LongMethod:
active: false
LongParameterList:
active: false
CyclomaticComplexMethod:
active: false
NestedBlockDepth:
active: false
ComplexCondition:
active: true
LargeClass:
active: true
naming:
VariableNaming:
active: true
TopLevelPropertyNaming:
active: true
FunctionNaming:
active: true
ignoreAnnotated: [ 'Composable' ]
LambdaParameterNaming:
active: true
NonBooleanPropertyPrefixedWithIs:
active: true
VariableMaxLength:
active: true
performance:
SpreadOperator:
active: false
CouldBeSequence:
active: true
UnnecessaryPartOfBinaryExpression:
active: true
# Note: all rules for `comments` are disabled by default, but I put them here to be aware of their existence
comments:
AbsentOrWrongFileLicense:
active: false
CommentOverPrivateFunction:
active: false
CommentOverPrivateProperty:
active: false
DeprecatedBlockTag:
active: true
EndOfSentenceFormat:
active: true
OutdatedDocumentation:
active: true
allowParamOnConstructorProperties: true
UndocumentedPublicClass:
active: false
UndocumentedPublicFunction:
active: false
UndocumentedPublicProperty:
active: false
Compose:
CompositionLocalAllowlist:
active: true
# You can optionally define a list of CompositionLocals that are allowed here
allowedCompositionLocals:
- LocalCompoundColors
- LocalSnackbarDispatcher
- LocalCameraPositionState
- LocalMediaItemPresenterFactories
- LocalTimelineItemPresenterFactories
- LocalRoomMemberProfilesCache
- LocalMentionSpanUpdater
- LocalAnalyticsService
- LocalBuildMeta
- LocalUiTestMode
- LocalSdkIntVersionProvider
CompositionLocalNaming:
active: true
ContentEmitterReturningValues:
active: true
# You can optionally add your own composables here
# contentEmitters: MyComposable,MyOtherComposable
ModifierComposable:
active: true
ModifierMissing:
active: true
ModifierReused:
active: true
ModifierWithoutDefault:
active: true
MultipleEmitters:
active: true
# You can optionally add your own composables here
# contentEmitters: MyComposable,MyOtherComposable
MutableParams:
active: true
ComposableNaming:
active: true
# You can optionally disable the checks in this rule for regex matches against the composable name (e.g. molecule presenters)
# allowedComposableFunctionNames: .*Presenter,.*MoleculePresenter
ComposableParamOrder:
active: true
PreviewAnnotationNaming:
active: true
PreviewPublic:
active: true
# You can optionally disable that only previews with @PreviewParameter are flagged
previewPublicOnlyIfParams: false
RememberMissing:
active: true
UnstableCollections:
active: true