voxpupuli / puppet-lint-strict_indent-check

indent check for puppet-lint
Mozilla Public License 2.0
4 stars 11 forks source link

Reporting incorrect line number #5

Closed relud closed 8 years ago

relud commented 8 years ago

=== Original file ===

# doc
class agent(
$group = '',
){
}

== Example run ==

$ puppet-lint init.pp
./manifests/init.pp - WARNING: indent should be 2 chars and is 0 on line 2
relud commented 8 years ago

what I get === Original file ===

# doc
class agent(
$group = '',
){
}

== Example run ==

$ puppet-lint init.pp
ERROR: agent not in autoload module layout on line 2
WARNING: indent should be 2 chars and is 0 on line 3

closing worksforme

wybczu commented 8 years ago

Can you re-open the issue? It seems that line number is reported incorrectly:

=== Original file ===

# doc
class agent(
$group = '',
){
}

== Example run ==

$ puppet-lint --only-checks strict_indent file.pp    
WARNING: indent should be 2 chars and is 0 on line 3

Interesting thing - when I run puppet-lint -f on this file it's being fixed correctly.

wybczu commented 8 years ago

From what I can see in the code, using token.next_token in notify for line number and column should fix the issue.

relud commented 8 years ago

line 3 is $group = '',, which is the one that's incorrectly indented

wybczu commented 8 years ago

I'm really sorry - wrong c&p:

$ nl file.pp 
     1  # doc
     2  class agent(
     3  $group = '',
     4  ){
     5  }

$ puppet-lint --only-checks strict_indent --with-context file.pp
WARNING: indent should be 2 chars and is 0 on line 2

  class agent(
              ^

I have the same issue with the following file:

$ nl file2.pp
     1  class some_claas(
     2    $param
     3  ){
     4      some::resource { 'dummy':
     5        param => $param,
     6      }
     7  }

$ puppet-lint --only-checks strict_indent --with-context file2.pp
WARNING: indent should be 2 chars and is 4 on line 3

  ){
    ^

WARNING: indent should be 4 chars and is 6 on line 4

  some::resource { 'dummy':
                           ^

WARNING: indent should be 2 chars and is 4 on line 5

  param => $param,
                  ^
relud commented 8 years ago

could you give me your include puppet-lint version and ruby version for testing

wybczu commented 8 years ago
$ bundle exec ruby --version
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
$ bundle exec gem list

*** LOCAL GEMS ***

bundler (1.12.5)
puppet-lint (2.0.2)
puppet-lint-strict_indent-check (2.0.3)
wybczu commented 8 years ago

Tested also on

ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux-gnu]
jijojv commented 8 years ago

Thank you for creating this plug-in. Line number is off by one on all my files

ERROR: agent not in autoload module layout on line 2 WARNING: indent should be 2 chars and is 0 on line 2

$ nl a.pp
     1  # doc
     2  class agent(
     3  $group = '',
     4  ){
     5  }

ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
puppet-lint (2.0.2, 2.0.0, 1.1.0)
puppet-lint-strict_indent-check (2.0.3)
relud commented 8 years ago

thanks for the reports, i've been able to locate the source of the issue. token.line for a newline token changed from puppet-lint 1.0.1 to 1.1.0, causing this issue. I'll be releasing an updated gem to fix it.

relud commented 8 years ago

released 2.0.4 to fix this

wybczu commented 8 years ago

Thank you! Line numbers are reported correctly with 2.0.4.