Fix CPD and Detekt lint issues

This commit is contained in:
Kirill Nayduik 2021-06-23 23:47:58 +03:00
parent 0f1a51a7aa
commit ef8144b41c
6 changed files with 13 additions and 10 deletions

View File

@ -9,7 +9,7 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx4096m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

View File

@ -48,6 +48,7 @@ abstract class MviViewModel<NavArgs : Parcelable, Action : ViewAction, State : V
protected val navArgs: NavArgs = handle.get(MviFragment.INIT_ARGS_KEY) ?: throw IllegalStateException("Nav args mustn't be null")
@SuppressWarnings("detekt.VariableNaming")
protected val _state = MutableLiveData(initialState)
internal val state = Transformations.distinctUntilChanged(_state)

View File

@ -13,7 +13,7 @@ class ViewModelFactory(
) : AbstractSavedStateViewModelFactory(owner, arguments) {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T {
return viewModelMap[modelClass]?.create(handle) as? T ?: throw IllegalStateException("Unknown ViewModel class")
}
override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T =
viewModelMap[modelClass]?.create(handle) as? T ?: throw IllegalStateException("Unknown ViewModel class")
}

View File

@ -430,7 +430,8 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
sourceBuilder.migration, sourceBuilder.defaultValue, sourceBuilder.storeScheduler, sourceBuilder.cacheTimeMillis);
}
@SuppressWarnings({"PMD.ExcessiveParameterList", "CPD-START"})
@SuppressWarnings("PMD.ExcessiveParameterList")
//CPD-OFF
//CPD: it is same code as constructor of Storable
//ExcessiveParameterList: that's why we are using builder to create it
private BuilderCore(@NonNull final TKey key,
@ -455,7 +456,7 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
this.cacheTimeMillis = cacheTimeMillis;
}
@SuppressWarnings("CPD-END")
//CPD-ON
protected void setStoreSchedulerInternal(@Nullable final Scheduler storeScheduler) {
this.storeScheduler = storeScheduler;
}

View File

@ -63,8 +63,8 @@ public class NonNullStorable<TKey, TObject, TStoreObject> extends BaseStorable<T
* @param <TObject> Type of actual object;
* @param <TStoreObject> Type of store object. Could be same as {@link TObject}.
*/
@SuppressWarnings("CPD-START")
//CPD: it is same code as Builder of Storable because it's methods returning this and can't be inherited
// CPD-OFF
// CPD: it is same code as Builder of Storable because it's methods returning this and can't be inherited
public static class Builder<TKey, TObject, TStoreObject> extends BuilderCore<TKey, TObject, TStoreObject> {
public Builder(@NonNull final Storable.Builder<TKey, TObject, TStoreObject> sourceBuilder,
@ -133,7 +133,8 @@ public class NonNullStorable<TKey, TObject, TStoreObject> extends BaseStorable<T
* @return New {@link NonNullStorable}.
*/
@NonNull
@SuppressWarnings("CPD-END")
// CPD-ON
public NonNullStorable<TKey, TObject, TStoreObject> build() {
if (getDefaultValue() == null) {
throw new ShouldNotHappenException();

View File

@ -47,7 +47,7 @@ class AmountWithDecimalDecorator(
fun getTextWithoutFormatting(decimalSeparatorToReplace: String = decimalSeparator): String =
previousInputtedText.withoutFormatting(decimalSeparatorToReplace)
@Suppress("detekt.TooGenericExceptionCaught")
@Suppress("detekt.TooGenericExceptionCaught", "detekt.ComplexMethod", "detekt.LongMethod")
private fun doOnTextChanged(text: String) {
if (isTextWasArtificiallyChanged) {
isTextWasArtificiallyChanged = false