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

violation source line %r display when blank lines in element #734

Closed
kryde opened this issue Feb 2, 2017 · 6 comments
Closed

violation source line %r display when blank lines in element #734

kryde opened this issue Feb 2, 2017 · 6 comments
Labels
Milestone

Comments

@kryde
Copy link

kryde commented Feb 2, 2017

In debian packaged perlcritic 1.126, if an element contains blank lines then the source %r displayed for a violation is wrong. For example perlcritic --severity 1 --verbose=9 foo.pl attached shows

[ValuesAndExpressions::RequireInterpolationOfMetachars] String may require interpolation at line 3, near ''. (Severity: 1)

whereas I hoped it would be "near '@bar'".

Some inputs provoke an unitialized value warning too, for example bar.pl attached run similarly.

In Perl::Critic::Violation I think the split in _line_containing_violation() collapses blank lines since \s* matches newlines. Some of the flags are trying to affect that are they? For the uninitialized I think $inx would be compared to $#lines not @lines. I get some joy from splitting on newline and trimming leading whitespace later like diff below.

foo.pl.txt
bar.pl.txt
Violation.pm.diff.txt

@xsawyerx
Copy link
Collaborator

I believe it's the same bug #702 fixes.

@petdance petdance added this to the 1.127 milestone May 17, 2017
@bar
Copy link

bar commented May 17, 2017

@kryde mhhh? I don't think you wanted to at handle me...

@petdance
Copy link
Member

Sorry about that. It's an artifact of referring to the Perl variable @bar.

@petdance
Copy link
Member

@xsawyerx Is this fixed? Is there a test for it?

@petdance petdance modified the milestones: 1.128, 1.127_01 May 18, 2017
@xsawyerx
Copy link
Collaborator

@petdance On it. Expect one this evening.

xsawyerx added a commit to xsawyerx/Perl-Critic that referenced this issue May 18, 2017
This test checks a problems with the line tracking for violations.

* It doesn't seem to fail on 5.22.1, but it does on 5.18.2.
* If you have the policy 'CodeLayout::ProhibitHashBarewords', it
  will use that for the test.
* If you don't, it won't do anything.
@xsawyerx
Copy link
Collaborator

Done: #758.

@petdance petdance added the Bug label May 18, 2017
petdance pushed a commit that referenced this issue May 20, 2017
This test checks a problems with the line tracking for violations.

* It doesn't seem to fail on 5.22.1, but it does on 5.18.2.
* If you have the policy 'CodeLayout::ProhibitHashBarewords', it
  will use that for the test.
* If you don't, it won't do anything.
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

4 participants