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

Line numbers off after multi-line strings with variables #736

Closed
cbowman0 opened this issue Aug 24, 2017 · 3 comments
Closed

Line numbers off after multi-line strings with variables #736

cbowman0 opened this issue Aug 24, 2017 · 3 comments
Milestone

Comments

@cbowman0
Copy link
Contributor

When parsing a multi-line strings with variables in them, the line numbers are incorrect. The line numbers being off causes the https://github.com/relud/puppet-lint-strict_indent-check to get lost and report non-existent errors.

There may be a smart way to change the strict_indent check to not get confused.

The line numbers appear to go wrong at https://github.com/rodjek/puppet-lint/blob/master/lib/puppet-lint/lexer.rb#L469 When the VARIABLE token is inserted, if it has a line number that doesn't reflect the previous changes to line_no in new_token() of the DQPRE entry.

@cbowman0
Copy link
Contributor Author

Example contrived syntax that shows line numbers are off:

class test {
  exec {'a':
    command     => "/bin/sh \
      /usr/bin/${test::command} >> \
      /var/log/a.log 2>&1",
     refreshonly => true;
  }
}

Executed shows the indentation error:

$ puppet-lint --only-checks 2sp_soft_tabs --relative --with-context --with-filename init.pp
init.pp - ERROR: two-space soft tabs not used on line 5

  /var/log/a.log 2>&1",
  ^

But the actual error line is line 6 refreshonly => true;

@cbowman0
Copy link
Contributor Author

When the following is invoked with the invoked with the strict_indent plugin:

class test {

  exec {'a':
    subscribe   => Package["a-${test::a_version}"],
    refreshonly => true,
    command     => "/bin/sh \
      /usr/bin/${test::command} >> \
      /var/log/a.log 2>&1";
  }

  exec {'b':
    subscribe   => Package["b-${test::b_version}"],
    refreshonly => true,
    command     => "/bin/sh \
      /usr/bin/${test::command} >> \
      /var/log/b.log 2>&1";
  }

}

The errored output is:

puppet-lint --only-checks 2sp_soft_tabs,strict_indent --relative --with-context --with-filename init.pp
init.pp - WARNING: indent should be 2 chars and is 4 on line 11

  exec {'b':
  ^

with the complained about line being line 11, but actually it's complaining about line 12. When it does that, then the arrow_alignment checks start complaining about lines 13 and 14. After that any fix involves strict_indent and arrow_alignment complaining about the other plugin's fix.

Implementing the fix in #737 makes this issue stop happening.

@rodjek rodjek added this to the Next release (2.4.0 maybe?) milestone Sep 25, 2017
@rodjek
Copy link
Owner

rodjek commented Sep 25, 2017

#737 has been merged

@rodjek rodjek closed this as completed Sep 25, 2017
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

No branches or pull requests

2 participants