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

Adding Groovy Linter to Github Super-Linter #69

Closed
admiralAwkbar opened this issue Jul 14, 2020 · 9 comments · Fixed by #74
Closed

Adding Groovy Linter to Github Super-Linter #69

admiralAwkbar opened this issue Jul 14, 2020 · 9 comments · Fixed by #74

Comments

@admiralAwkbar
Copy link

Hey!

I'm working on adding the npm-groovy-linter to the GitHub Super-Linter

But I'm getting some odd behavior when testing the system, and getting bad results...

Any Idea why it's not understanding the test case?

bash-5.0# npm-groovy-lint -s bad.groovy 
0
  0     info     File codeNarcTmpDir_0.2818605574397848.groovy does not end with a newline  FileEndsWithoutNewline  
  1     warning  Class should be marked with one of @GrailsCompileStatic, @CompileStatic or @CompileDynamic  CompileStatic           


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      1      │
│    2    │  'Info'   │      1      │
└─────────┴───────────┴─────────────┘

Contents of bad.groovy:

Example {
   void main(String[] args) {
      File file = new File("E:/Example.txt")
      println "The file ${file.absolutePath} has ${file.length()} bytes
   } 
}
@admiralAwkbar
Copy link
Author

admiralAwkbar commented Jul 14, 2020

Tried to get it working a different way and it just doesn't show output for the second file...

bash-5.0# npm-groovy-lint --path "./test" --files "**/*.groovy" --verbose
/test/good.groovy
  2     warning  Class should be marked with one of @GrailsCompileStatic, @CompileStatic or @CompileDynamic  CompileStatic           


npm-groovy-lint results in 2 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      1      │
│    2    │  'Info'   │      0      │

As from above, I have a good.groovy and a bad.groovy, the good is a syntax-correct file, and the bad is set to:

/* Hello World in Groovy */
pr ('some dank")  

Does it seem to just skip it in output?

@nvuillam
Copy link
Owner

I think that if you want to analyze the results of several groovy files, you should use --output json :)
The text output is more for a human to read

@admiralAwkbar
Copy link
Author

@nvuillam Can you help me understand why it's not showing data for the second file with the bad data? Is my command incorrect or am I looking at this wrong? Any help is much appreciated

@nvuillam
Copy link
Owner

Plz can you fork the repo , add your test case in errors.test.js and send me the link, so I can reproduce the issue ?

@admiralAwkbar
Copy link
Author

Hey @nvuillam sorry got sidetracked and didn't have a ton of time...
You can recreate this test by:

  • Install npm-groovy-lint
  • create a folder called test
    • mkdir test
  • create file groovy-bad.groovy
class Example {
   static void main(String[] args) {
      File file = new File("E:/Example.txt")
      println "The file ${file.absolutePath} has ${file.length()} bytes"
   }
}
class Example{
some noise here
}
  • Run linter against the file
bash-5.0# npm-groovy-lint --failon error --path "./test" --files "**/bad.groovy"

npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      0      │
│    2    │  'Info'   │      0      │
└─────────┴───────────┴─────────────┘
bash-5.0# echo $?
0

As you can see, it shows 1 linted file, but none of the output, and error code is 0

Can you help me understand what i may be doing wrong?

Working case

If I point it to a file with decent data, it works as expected

Example of good.groovy:

class Example {
   static void main(String[] args) {
      File file = new File("E:/Example.txt")
      println "The file ${file.absolutePath} has ${file.length()} bytes"
   }
}

Output

bash-5.0# npm-groovy-lint --failon error --path "./test" --files "**/good.groovy"
/tests/good.groovy
  1     warning  Class `Example` is the only class in `good.groovy`. In such a case the file and the class should have the same name.  ClassNameSameAsFilename
  1     warning  Class should be marked with one of @GrailsCompileStatic, @CompileStatic or @CompileDynamic  CompileStatic
  2     info     Class does not start with a blank line after the opening brace  ClassStartsWithBlankLine
  2     info     The method main in class Example is at the incorrect indent level: Expected column 5 but was 4  Indentation
  3     info     The statement on line 3 in class Example is at the incorrect indent level: Expected column 9 but was 7  Indentation
  3     warning  The use of java.io.File violates the Enterprise Java Bean specification  JavaIoPackageAccess
  3     info     The String 'E:/Example.txt' can be wrapped in single quotes instead of double quotes  UnnecessaryGString
  4     info     The statement on line 4 in class Example is at the incorrect indent level: Expected column 9 but was 7  Indentation
  5     info     Line ends with whitespace characters  TrailingWhitespace
  6     info     Class does not end with a blank line before the closing brace  ClassEndsWithBlankLine


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      3      │
│    2    │  'Info'   │      7      │
└─────────┴───────────┴─────────────┘
bash-5.0#

@nvuillam
Copy link
Owner

nvuillam commented Jul 22, 2020

It seems that CodeNarc does not write in its XML output file when there is a parse error

image

I'll try to find a solution

@nvuillam
Copy link
Owner

Working on the solution... I'll keep you informed :)

@admiralAwkbar
Copy link
Author

@nvuillam awesome. Even if it just marked the file as failed to parse and exited with error, that would achieve the main goal

@nvuillam
Copy link
Owner

@admiralAwkbar please can you check with latest version ? (v5.7.0)

I had to embed Ant in the package, but now every file is parsed before being sent to CodeNarc, so all parsing errors are returned

Please reopen if you still see any problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants