npm-groovy-lint icon indicating copy to clipboard operation
npm-groovy-lint copied to clipboard

bug: Wrong indentation for comments

Open berthin opened this issue 8 months ago • 1 comments

Hi,

using the pre-commit hook format-npm-groovy-lint, comments are not formatted correctly. See for instance the following example:

class MyClass {
      /**
      * Some documentation
      *
      * This bla bla bla bla
      */
  static String helloWorld() {
    "Hello World"
  }
}

the comments are indented with 6 spaces, the groovy linter rc file specifies a 2 space indentation, but the pre-commit hook doesn't complain.

I am using this pre-commit configuration

repos:                                                                                
  - repo: https://github.com/nvuillam/npm-groovy-lint                                 
    rev: v14.6.0                                                                      
    hooks:                                                          
      - id: format-npm-groovy-lint                                                    
        name: Format Lint groovy findings                                             
        description: Groovy & Jenkinsfile Formatter                                   
        entry: npm-groovy-lint --format                                               
        language: node  

Another thing I found is if I add comments at the end of the function:

class MyClass {
      /**
      * Some documentation
      *
      * This bla bla bla bla
      */
  static String helloWorld() {
    "Hello World"

    // Note: this is another comment
    // bla bla bla
  }
}

then, the formatter decreases the alignment by 1

class MyClass {
      /**
      * Some documentation
      *
      * This bla bla bla bla
      */
  static String helloWorld() {
    "Hello World"

  // Note: this is another comment
  // bla bla bla
  }
}

Not sure if this by design, or a bug.

berthin avatar Jun 18 '24 15:06 berthin