• marschwar

    marschwar

    2 years ago
    Hi guys, are any of the maintainers going to be at KotlinConf?
    marschwar
    s
    2 replies
    Copy to Clipboard
  • adam-mcneilly

    adam-mcneilly

    2 years ago
    High level question: is there any way to have detekt enforce that you use named arguments? Specifically, I was thinking this would be helpful for methods or constructors that have say at least 3 arguments. I haven't found anything in the detekt config that relates to this, but I'm also not sure if it's possible - how would static analysis know if the method I'm calling supports named arguments - it might not if it's a java interrop, right?
    adam-mcneilly
    s
    4 replies
    Copy to Clipboard
  • thuytrinh

    thuytrinh

    2 years ago
    Hi folks. I’m trying to use
    Duration
    type https://okkotlin.com/duration/ but it got flagged by the
    MagicNumber
    rule. Just wondering whether anyone knows how to configure the
    MagicNumber
    to exclude if I extract the whole
    Duration
    into a constant like below?
    @ExperimentalTime
    class Operation {
        companion object {
            val DEFAULT_TIMEOUT = 3.seconds
        }
    
        @ExperimentalTime
        fun read(timeout: Duration = DEFAULT_TIMEOUT) {
        }
    }
    So w/ that example, detekt still complains that
    3
    should be constant.
    thuytrinh
    1 replies
    Copy to Clipboard
  • Jukka Siivonen

    Jukka Siivonen

    2 years ago
    This is somehow related to Kotlin update 1.3.50 -> 1.3.60 because I get this also using 1.3.60 and Detekt 1.0.1
    Jukka Siivonen
    b
    4 replies
    Copy to Clipboard
  • Czar

    Czar

    2 years ago
    detekt 1.2.0 Spring Boot 2.2.1 Kotlin 1.3.60 I have
    kotlin.spring
    plugin applied and a class annotated with
    @Configuration
    , but
    ProtectedMemberInFinalClass
    is still triggered. The class is effectively open due to kotlin.springplugin and this worked before on detekt 1.0.1, Boot 2.2.0.RC1, Kotlin 1.3.50. Should I try to downgrade them one by one to find which version upgrade caused this or is it a known issue?
    Czar
    s
    +2
    8 replies
    Copy to Clipboard
  • r

    robstoll

    2 years ago
    got a regression updating from 1.2.0 to 1.2.1
    Could not set unknown property 'filters' for object of type io.gitlab.arturbosch.detekt.extensions.DetektExtension.
    is this on purpose?
    r
    Jukka Siivonen
    3 replies
    Copy to Clipboard
  • sanogueralorenzo

    sanogueralorenzo

    2 years ago
    Hello people, after updating from 1.1.1 to 1.2.1 when running
    detektAll
    a centric baseline is ignored. I switched to
    build.gradle.kts
    to ensure that wasn't the issue and was checking detekt project and it is set the same way (and also have the same path)
    baseline.set(file("$rootDir/config/detekt/baseline.xml"))
    Was there any change regarding baseline? I don't seem to find it looking through 1.2.0 and 1.2.1
    sanogueralorenzo
    s
    4 replies
    Copy to Clipboard
  • Czar

    Czar

    2 years ago
    Can I disable a rule only in IntelliJ, without affecting gradle build and committing anything? So far I've thought of following options (both of which I don't like):1. copy-paste my detekt.yml from the project to a place outside project, make the change I want, configure plugin with that file while leaving gradle config intact. Negative here is that I have to be on lookout for additional changes to detekt.yml from the repo and not forget to update my local file 2. change the file in the project and move it to a separate "local only" changelist to avoid commiting it. Downside: bit risky, at some point can still commit it unintentionally, e.g. from command line. I need this to suppress ForbiddenComments for
    todo:
    , but only in IntelliJ, because I use
    todo:
    comments when working on a changeset. Showing those as errors kinda messes with the flow. On the other hand I wouldn't want to commit them, so I need them to be reported when I run gradle check
    Czar
    p
    +1
    3 replies
    Copy to Clipboard
  • Czar

    Czar

    2 years ago
    In a simple entity update situation, where there's an entity
    class MyEntity {
      val id: Long? = null
      var prop1: String? = null
      var prop2: String? = null
    // ...
      var propN: String? = null
    }
    and an update command:
    class UpdateEntityCommand {
      val myEntityId: Long
      var prop1: String? = null
      var prop2: String? = null
    // ...
      var propN: String? = null
    }
    the handler should only change property of the entity if corresponding property of the command is not
    null
    :
    class MyHandler(private val repo: MyEntityRepository) {
      fun handle(command: UpdateEntityCommand) {
        with(repository.getOne(command.myEntityId)) {
          // (1)
          if (command.prop1 != null) prop1 = command.prop1
          // (2)
          command.prop2?.let { prop2 = it }
          // (3)
          ifNotNull(command.propN) { propN = it }
        }
      }
    }
    If all the properties are set using method (1) or (3), detekt is happy, if method (2) is used, detekt is complaining about
    "ComplexMethod"
    Should I report this to the issue tracker, or is it as it should be? If the latter, I wonder why?
    Czar
    b
    2 replies
    Copy to Clipboard
  • Eugen Martynov

    Eugen Martynov

    2 years ago
    abstract class MemoryCache<T> {
    
        private val cachedValue = AtomicReference<T>()
    
        fun getOrEmpty(): Maybe<T> = Maybe.fromCallable { cachedValue.get() }
    
        fun set(value: T) {
            this.cachedValue.set(value)
        }
    
        fun invalidate() {
            cachedValue.set(null)
        }
    }
    This class has concrete methods
    Eugen Martynov
    m
    +1
    7 replies
    Copy to Clipboard