alaegin / Detekt-Action

Run Detekt with reviewdog
MIT License
23 stars 24 forks source link

Invalid Configuration file issue with Detekt-Action@1.23.0 #49

Closed harigovind1 closed 1 year ago

harigovind1 commented 1 year ago

io.gitlab.arturbosch.detekt.api.Config$InvalidConfigurationError: Provided configuration file is invalid: Structure must be from type Map<String,Any>!

GH action usage. We have prior step to download correct version of jar

- name: Run detekt with reviewdog
        uses: alaegin/Detekt-Action@v1.23.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          detekt_config: kotlin/detekt/detekt.yaml
          reviewdog_reporter: github-pr-check
          detekt_plugins: 'kotlin/detekt/plugins/detekt-formatting.jar'

Error trace:

java -jar /opt/detekt.jar --config kotlin/detekt/detekt.yaml --report xml:detekt_report.xml --excludes **/build/**,**/.idea/** --plugins /opt/detekt-formatting.jar,kotlin/detekt/plugins/detekt-formatting.jar 
io.gitlab.arturbosch.detekt.api.Config$InvalidConfigurationError: Provided configuration file is invalid: Structure must be from type Map<String,Any>!
while constructing a mapping
 in reader, line 1, column 1:
    build:
    ^
found duplicate key formatting
 in reader, line 1057, column 1:
    formatting:
    ^

    at io.gitlab.arturbosch.detekt.core.config.YamlConfig$Companion.load(YamlConfig.kt:77)
    at io.gitlab.arturbosch.detekt.core.tooling.DefaultConfigProviderKt.getDefaultConfiguration(DefaultConfigProvider.kt:55)
    at io.gitlab.arturbosch.detekt.core.tooling.DefaultConfigProviderKt.getDefaultConfiguration(DefaultConfigProvider.kt:59)
    at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$run$1.invoke(AnalysisFacade.kt:26)

Sample config file(kotlin/detekt/detekt.yaml ) - This is working fine with previous versions 1.22.0

formatting:
  active: true
  autoCorrect: true
  FinalNewline:
    active: true
  NoUnusedImports:
    active: true
  ArgumentListWrapping:
    active: false

style:
  MaxLineLength:
    maxLineLength: 150
    excludeCommentStatements: true
  ReturnCount:
    max: 5
  ForbiddenComment:
    active: false
  UnnecessaryAbstractClass:
    active: false

complexity:
  LongParameterList:
    active: true
    functionThreshold: 6
    constructorThreshold: 20
    ignoreAnnotated:
      - Table
  LongMethod:
    threshold: 80
  TooManyFunctions:
    thresholdInFiles: 15
    thresholdInClasses: 15
    thresholdInInterfaces: 15
    thresholdInObjects: 15
    thresholdInEnums: 15
    ignorePrivate: true
  CyclomaticComplexMethod:
    threshold: 15
  CognitiveComplexMethod:
    threshold: 15

comments:
  UndocumentedPublicClass:
    active: false
  UndocumentedPublicFunction:
    active: false
  UndocumentedPublicProperty:
    active: false
  EndOfSentenceFormat:
    active: false
  CommentOverPrivateFunction:
    active: false
  CommentOverPrivateProperty:
    active: false

naming:
  FunctionMaxLength:
    active: true
    maximumFunctionNameLength: 100

coroutines:
  active: true

potential-bugs:
  active: true
alaegin commented 1 year ago

Hello!

Could you please try to remove detekt_plugins from your config? detekt-formatting plugin should work out of the box as It's already bundled

harigovind1 commented 1 year ago

Hello!

Could you please try to remove detekt_plugins from your config? detekt-formatting plugin should work out of the box as It's already bundled

@alaegin Thanks for looking into this. As mentioned removing detekt_plugins from config fixes issue