szpak / gradle-pitest-plugin

Gradle plugin for PIT Mutation Testing
http://gradle-pitest-plugin.solidsoft.info/
213 stars 58 forks source link

Lint Groovy files with CodeNarc #184

Closed 3flex closed 4 years ago

3flex commented 4 years ago

Closes #78

There are 6 CodeNarc rulesets that weren't applied:

  1. comments - for future consideration
  2. enhanced - need to provide project's classpath to CodeNarc so it can perform more detailed analysis, so left it out for now
  3. grails - not used by this project
  4. jdbc - not used by this project
  5. security - seems more relevant for daemons, though removing direct usage of java.io.File (see https://github.com/szpak/gradle-pitest-plugin/pull/183#issuecomment-593074829) should allow this ruleset to be enabled without any other changes
  6. size - would require too much refactoring to apply in this PR

A few specific rules have been excluded as well - DuplicateStringLiteral and LineLength would be easy to fix, I just didn't have the time today. JUnitPublicNonTestMethod and MethodName caused problems in the test sourcesets, and UnnecessaryGetter looked like it was warning on usage of the Gradle property API, and making the suggested changes would have caused compilation failures.

Just a warning that I've had minimal exposure to Groovy outside of Gradle (and its sources) and have never used CodeNarc before, so this will require a careful review. I'm happy to revert any of these changes or disable any rules that don't fit with the project's code style.

szpak commented 4 years ago

I wonder @3flex, if you had any problems with my last remarks and need some assistance to move it forward?

3flex commented 4 years ago

Just very short on time at the moment! I'll try to get to it in the next couple of days, I still intend to update based on your feedback.

szpak commented 4 years ago

I merged it manually with some minor adjustments. Thanks for your work!

szpak commented 4 years ago

@3flex FYI, CodeNarc currently (as of 1.5) doesn't work with Java 14 (https://github.com/gradle/gradle/issues/12646).