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

Error negative argument if opening brace on the same line and following element longer #771

Closed
vicinus opened this issue Oct 7, 2017 · 1 comment
Labels
Milestone

Comments

@vicinus
Copy link

vicinus commented Oct 7, 2017

This is probably the same issue as #723 but as the error description is cut short, I can't be sure...

puppet-lint --fix test.pp

puppet-lint version: 2.3.3
ruby version: 2.3.1-p112
platform: x86_64-linux-gnu
file path: x.pp
file contents:

res { 'a':
  x => { 'a' => '',
    'ab' => '',
  }
}

error:

ArgumentError: negative argument
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb:105:in `*'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb:105:in `fix'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checkplugin.rb:42:in `block in fix_problems'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checkplugin.rb:38:in `each'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checkplugin.rb:38:in `fix_problems'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checks.rb:63:in `block in run'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checks.rb:57:in `each'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/checks.rb:57:in `run'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint.rb:196:in `run'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/bin.rb:59:in `block in run'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/bin.rb:56:in `each'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/lib/puppet-lint/bin.rb:56:in `run'
/var/lib/gems/2.3.0/gems/puppet-lint-2.3.3/bin/puppet-lint:7:in `<top (required)>'
/usr/local/bin/puppet-lint:23:in `load'
/usr/local/bin/puppet-lint:23:in `<main>'

I have started working on a fix, but reading the newest puppet style guide I think that the following spec test is wrong:

    context 'multiline hash with opening brace on same line as first pair' do
      let(:code) do
        <<-END
          foo { 'foo':
            bar => [
              { aa => bb,
                c  => d},
            ],
          }
        END
      end

      it 'should not detect any problems' do
        expect(problems).to have(0).problems
      end
    end

because the latest style guide declares as bad:

# hash with multiple elements on different lines, but syntax and element share a line
$myhash = { key => 'some value',
  other_key     => 'some other value',
}

So should a fix implement a special case handling for opening brace on the same line as first element or would be a fix acceptable that enforces that opening brace and first element on the same line is an (fixable) issue?

@rodjek rodjek added this to the 2.3.4 milestone Nov 2, 2017
@rodjek
Copy link
Owner

rodjek commented Nov 13, 2017

For now, the check should be fixed in a way that maintains the behaviour in the specs. The style guide has been updated, but modifying the check behaviour will need to wait for a major version bump.

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

No branches or pull requests

2 participants