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

--format doesn't respect custom Indentation #31

Closed
b1zzu opened this issue Apr 28, 2020 · 4 comments · Fixed by #32
Closed

--format doesn't respect custom Indentation #31

b1zzu opened this issue Apr 28, 2020 · 4 comments · Fixed by #32

Comments

@b1zzu
Copy link

b1zzu commented Apr 28, 2020

Hi,
this is may groovy file:

pipeline {
  agent none
  options {
    timestamps()
    ansiColor('xterm')
  }
  stages {
    stage('stuff') {
      steps {
        sh 'echo "stuff"'
      }
    }
  }
}

and this is my .groovylintrc.json configuration:

{
  "extends": "recommended-jenkinsfile",
  "rules": {
    "Indentation": {
      "spacesPerIndentLevel": 2
    }
  }
}

as you can see the groovy file is correct and if I analyze the file it doesn't report any error

➜ npm-groovy-lint         

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

but if I try to automatically format it will indent everything with four spaces instant of two

➜  npm-groovy-lint --format
/home/b1zzu/Projects/gitlab.cee.redhat.com/integreatly-qe/ci-cd/stuff/test.groovy


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

and if I analyze again the modified it will show indentation problems:

➜  npm-groovy-lint         
/home/b1zzu/Projects/gitlab.cee.redhat.com/integreatly-qe/ci-cd/stuff/test.groovy
  2     info     The statement on line 2 in class None is at the incorrect indent level: Expected column 3 but was 5  Indentation             
  3     info     The statement on line 3 in class None is at the incorrect indent level: Expected column 3 but was 5  Indentation             
  4     info     The statement on line 4 in class None is at the incorrect indent level: Expected column 5 but was 9  Indentation             
  5     info     The statement on line 5 in class None is at the incorrect indent level: Expected column 5 but was 9  Indentation             
  7     info     The statement on line 7 in class None is at the incorrect indent level: Expected column 3 but was 5  Indentation             
  8     info     The statement on line 8 in class None is at the incorrect indent level: Expected column 5 but was 9  Indentation             
  9     info     The statement on line 9 in class None is at the incorrect indent level: Expected column 7 but was 13  Indentation             
  10    info     The statement on line 10 in class None is at the incorrect indent level: Expected column 9 but was 17  Indentation             


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

I plead guilty :p
When --format is called, .groovylintrc-format.json is called, and it ignores the custom .groovylintrc.json
The solution is to merge custom .groovylintrc.json into .groovylintrc-format.json so overrides are taken in account , it could be done by adding a if mode === 'format' then loadConfig(lint) then merge config.rules before returning results, there :

return configUser;

I'll do that when i have time, or you can make a PR if you''re in a hurry :)

@b1zzu
Copy link
Author

b1zzu commented Apr 28, 2020

Hi @nvuillam I will try to give a look in the evening maybe I manage to create the PR

nvuillam added a commit that referenced this issue Apr 28, 2020
Take in account user overridden indentation space (and other rules) when using --format option [#31](#31)
@nvuillam nvuillam linked a pull request Apr 28, 2020 that will close this issue
nvuillam added a commit that referenced this issue Apr 28, 2020
Take in account user overridden indentation space (and other rules) when using --format option [#31](#31)
nvuillam added a commit that referenced this issue Apr 28, 2020
Take in account user overridden indentation space (and other rules) when using --format option [#31](#31)
nvuillam added a commit that referenced this issue Apr 28, 2020
Take in account user overridden indentation space (and other rules) when using --format option [#31](#31)
@nvuillam
Copy link
Owner

@b1zzu fixed, please repoen the issue if you still see a problem :)

( not included in VsCode Groovy Lint yet, some updates may be necessary, i think there is a hardcoded "4" in VsCodeGroovyLint code which repaces tabs by spaces, I have to solve that before releasing a new version )

@nvuillam
Copy link
Owner

@b1zzu Evolution has been included in new VsCode Groovy Lint version 0.9.5 :)

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