Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VariableMinLength is in the wrong category #843

Closed
amagdaleno opened this issue Apr 4, 2018 · 15 comments
Closed

VariableMinLength is in the wrong category #843

amagdaleno opened this issue Apr 4, 2018 · 15 comments
Milestone

Comments

@amagdaleno
Copy link

amagdaleno commented Apr 4, 2018

Expected Behavior

Defining VariableMinLength under naming (as the default configuration does) should work, but doesn't

Current Behavior

If defined under naming the setting is ignored, instead it uses a default value of 3? and is reported under style instead of naming. Defining VariableMinLength under style does work.

Steps to Reproduce (for bugs)

Use default configuration and create a variable with an identifier length of 1 or 2

Context

It should go under naming to be honest

Your Environment

  • Version used: 1.0.0.RC6-4
@arturbosch
Copy link
Member

Totally right. Thanks for reporting!

@arturbosch
Copy link
Member

Could not reproduce it.

naming:
  VariableMinLength:
      active: true
      minimumVariableNameLength: 3

this configuration works for me and reports:

Ruleset: naming - 10min debt
	TopLevelPropertyNaming - [a] at /home/artur/Repos/detekt/detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NamingRules.kt:97:1
	VariableMinLength - [a] at /home/artur/Repos/detekt/detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NamingRules.kt:97:1

Are you sure you used RC6-4? Some versions ago we moved all naming rules from style to the new ruleset ...

@amagdaleno
Copy link
Author

Truth be told I am using detekt through https://github.com/vanniktech/gradle-code-quality-tools-plugin so if you can't reproduce the issue might stem from there. I've seen the author @vanniktech is active on this project when trying to debug this issue, so maybe he can shed some light on the matter, but if you'd rather go ahead and close this, I can open a ticket there.

And to answer your question I supposedly am, relevant configuration for codeQualityTools looks like this:

codeQualityTools {
    detekt {
        version = '1.0.0.RC6-4'
    }
}

@vanniktech
Copy link
Contributor

codeQualityTools {
    detekt {
        version = '1.0.0.RC6-4'
    }
}

is indeed correct. Is your yml configuration file for detekt under code_quality_tools/detekt.yml?

@amagdaleno
Copy link
Author

Yes, if I move the file gradle check fails with:
ParameterException: Provided path '/path/to/project/code_quality_tools/detekt.yml' does not exist!

@vanniktech
Copy link
Contributor

Is the project open source and I can take a look at it? Otherwise it's hard for me to debug. Also make sure to be on 0.10.0 of the Gradle Plugin.
Otherwise this works fine for me.

@amagdaleno
Copy link
Author

Unfortunately the project is not open source. I'm indeed using version 0.10.0:
classpath 'com.vanniktech:gradle-code-quality-tools-plugin:0.10.0'

I can set up a small project this afternoon to demonstrate if you want. If it's any help a detekt.yml containing only:

autoCorrect: false
failFast: true

naming:
  VariableMinLength:
    active: false

fails with a variable length of 2, but this one doesn't:

autoCorrect: false
failFast: true

style:
  VariableMinLength:
    active: false

@vanniktech
Copy link
Contributor

It works for me correctly. Here's a branch where you can play around with it - https://github.com/vanniktech/junit-rules/tree/VariableMinLength

Note though that VariableMinLength's minimumVariableNameLength has a default value of 1 which is always true.

@schalkms
Copy link
Member

Can we close this issue?

@vanniktech
Copy link
Contributor

I'd say yes.

@vanniktech
Copy link
Contributor

Worst case we're continuing in an issue on my repo.

@arturbosch
Copy link
Member

Ok, if it turns out to be an issue in detekt feel free to reopen :)

@vanniktech
Copy link
Contributor

@arturbosch I've debugged it and the problem is only when you also use failFast: true. In case you don't the rule is working as intended.

@arturbosch
Copy link
Member

Ok, any idea what is causing it? You had a minimal example repository?

@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants