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

How to test for trailing whitespace? #65

Open
loziniak opened this issue Dec 18, 2022 · 8 comments
Open

How to test for trailing whitespace? #65

loziniak opened this issue Dec 18, 2022 · 8 comments

Comments

@loziniak
Copy link
Member

loziniak commented Dec 18, 2022

In #62 I encountered a problem. I have a whitespace before comments (line comment 1, 2 and 3), but cannot write tests, because Rubocop complains during CI. Is this possible to:

  • turn off Rubocop trailing whitespace check

or

  • have snippet extractor cut trailing whitespace?
@loziniak
Copy link
Member Author

loziniak commented Dec 18, 2022

This is a sample code for snippet-extractor test:

          x: 1 ; line comment 1
          y: 11
          x: 2   ;-- line comment 2
          x: 3		;@@ line comment 3

Rubocop complains for the expected part:

          x: 1 
          y: 11
          x: 2   
          x: 3		

@joshiraez
Copy link
Collaborator

Mmm this is awry. The snippet extractor will always trim any whitespace from the lines (I have to double check but I'm quite sure the only thing it preserves are tabs/spaces at the start).

It rather seems a problem with Rubocop failing linting checks. Could you paste your error please? (Try first to check your other issue and limit your test to 10 lines to see if it keeps complaining and we can go from there)

@loziniak
Copy link
Member Author

log from Rubocop check:

warning: parser/current is loading parser/ruby26, which recognizes2.6.10-compliant syntax, but you are running 2.6.6.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Inspecting 39 files
.................................C.....

Offenses:

test/languages/red_test.rb:33:15: C: [Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
          x: 1 
              ^
test/languages/red_test.rb:35:15: C: [Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
          x: 2   
              ^^^
test/languages/red_test.rb:36:15: C: [Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
          x: 3		
              ^^

39 files inspected, 3 offenses detected, 3 offenses auto-correctable

@loziniak
Copy link
Member Author

#66 is fixed now, but here nothing changed.

loziniak added a commit to loziniak/snippet-extractor that referenced this issue Dec 19, 2022
@loziniak
Copy link
Member Author

In 0c374d9 I tried to get into account the fact, that Extractor will clear whitespace, but id didn't.

@joshiraez
Copy link
Collaborator

I'm quite sure this is a rubocop issue, but I think the extractor will remove any trailing whitespace at the right anyway, so you should be safe to remove those from the expected,

@joshiraez
Copy link
Collaborator

Oh wait, I just saw your commit. Let me take a look at this then

@loziniak
Copy link
Member Author

Hello, any news here?

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