AtomLinter / linter-phpcs

Linter plugin for PHP, using PHP_CodeSniffer.
63 stars 31 forks source link

fix column at end of tabbed line #383

Closed UziTech closed 5 years ago

UziTech commented 5 years ago

Fixes column > line length because of tabs

UziTech commented 5 years ago

The fixPHPCSColumn function returned the given column if the column is passed the end of the line. This will fix it so the column will be set to the end of the line instead of throwing an error that the column is not found.

UziTech commented 5 years ago

I trimmed down the sniff so it just puts an error at the end of every line.

UziTech commented 5 years ago

Looks like circleci is failing because of a configuration issue

image

UziTech commented 5 years ago

This should be ready to merge. I squashed the commits. The only reason the tests are failing is because of the circleci configuration issue above.

UziTech commented 5 years ago

@Arcanemagus is there a way to fix the error above?

UziTech commented 5 years ago

@Arcanemagus do you know how to fix the circleci error?

UziTech commented 5 years ago

@Arcanemagus I keep running into this same issue. Can we please get this merged?

Arcanemagus commented 5 years ago

I would greatly prefer phpcs to fix their inane handling of tabs, but I suppose that will never happen. I'm terribly sorry for the time it's taken to get back to this PR, and will take the time tonight determine why:

Again, sorry for the delay on this!

UziTech commented 5 years ago

This PR isn't really about tabs. Although linter-phpcs only runs into this bug on lines with tabs.

We get the line text with textEditor.getBuffer().lineForRow(line) which doesn't contain the line endings for the line.

So if the error is on the line ending the fixPHPCSColumn function returns the wrong column number.

This PR just fixes fixPHPCSColumn so it won't return a column past the length of the line including the line endings.

Arcanemagus commented 5 years ago

Co-opted this a bit to fix CircleCI (again), since I can't test it directly.

Arcanemagus commented 5 years ago

:tada: This PR is included in version 1.7.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: