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

RuboCopBear: Fix CI breakage #1890

Merged
merged 1 commit into from Jul 6, 2017
Merged

Conversation

@yash-nisar
Copy link
Member

@yash-nisar yash-nisar commented Jul 5, 2017

rubocop-hq/rubocop#4226 indicates that --stdin
takes filename as an argument which was incorporated. Also, the tests
were enhanced that involved the bear to be run on files with the .rb
(ruby) extension because initially the bear was run on the generated
temporary files that was the cause of error.

Fixes #1548

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Checklist

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    individually.
    It is not sufficient to have "fixup commits" on your PR,
    our bot will still report the issues for the previous commit.) You will
    likely receive a lot of bot comments and build failures if coala does not
    pass on every single commit!

After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.

Please consider helping us by reviewing other peoples pull requests as well:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

invalid_files=(bad_file,),
valid_files=(good_file,))
@generate_skip_decorator(RuboCopBear)
class RuboCopBearTest(LocalBearTestHelper):

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 5, 2017
Collaborator

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/ruby/RuboCopBearTest.py
+++ b/tests/ruby/RuboCopBearTest.py
@@ -23,6 +23,7 @@
 
 @generate_skip_decorator(RuboCopBear)
 class RuboCopBearTest(LocalBearTestHelper):
+
     def setUp(self):
         self.uut = RuboCopBear(Section('name'), Queue())
 
@yash-nisar yash-nisar force-pushed the yash-nisar:rubocop-investigation branch from 8794304 to 97d1d70 Jul 5, 2017
@@ -36,7 +36,7 @@ class RuboCopBear:
def create_arguments(filename, file, config_file, rubocop_config: str=''):
# Need both stdin and filename. Explained in this comment:
# https://github.com/bbatsov/rubocop/pull/2146#issuecomment-131403694
args = (filename, '--stdin', '--format=json')
args = ('--stdin', filename, '--format=json')

This comment has been minimized.

@jayvdb

jayvdb Jul 5, 2017
Member

Is this change compatible with earlier versions of rubocop?

This comment has been minimized.

@yash-nisar

yash-nisar Jul 5, 2017
Author Member

Yes 👍 , tested will versions 0.47.1, 0.48.1, 0.49.1


good_file = """def good_name

This comment has been minimized.

@jayvdb

jayvdb Jul 5, 2017
Member

why do we need to move the text out into real filenames?

Does rubocop require that there is a valid file with this filename?

Cant LocalBearTestHelper create temporary files with an appropriate filename/extension?

If it cant, then writing tests is much harder, which is sort of the anti-thesis of your project.

This comment has been minimized.

@yash-nisar

yash-nisar Jul 5, 2017
Author Member

Yes, rubocop requires that we have a valid filename extension (.rb). Temporary files were created in the previous case when we had to use verify_local_bear(...) but without a valid extension. See the commit message.

This comment has been minimized.

@jayvdb

jayvdb Jul 5, 2017
Member

So, you need to improve LocalBearTestHelper :P

This comment has been minimized.

@yash-nisar

yash-nisar Jul 5, 2017
Author Member

Actually, this is a linter specific problem. This is the first linter that I've come across that is careful about the filename extension. Moreover, it would make less sense IMO to improve LocalBearTestHelper to take care of this case only. Also we had to somehow improve the tests and use check_results(...) instead of verify_local_bear(...).

@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jul 5, 2017

@Makman2 Tagging you since this PR involved improvisation of tests.

@@ -19,7 +19,7 @@ class RuboCopBear:
"""

LANGUAGES = {'Ruby'}
REQUIREMENTS = {GemRequirement('rubocop', '0.47.1'),
REQUIREMENTS = {GemRequirement('rubocop'),

This comment has been minimized.

@Makman2

Makman2 Jul 5, 2017
Member

why did you remove the version specification?

This comment has been minimized.

@yash-nisar

yash-nisar Jul 6, 2017
Author Member

Our motive is to use the latest version of rubocop. We were using 0.47.1 in the earlier case and due to an upstream release i.e. 0.48, our CI broke. As a temporary fix, I had to pin the version to 0.47.1 to make sure that the tree was green again. Now that we have a solution, I think it would be a good option to get rid of the pinning and install the latest version.

This comment has been minimized.

@Makman2

Makman2 Jul 6, 2017
Member

though I would recommend to fix it currently for 0.48, and upgrade to newer releases explicitly with an issue. But up to you 👍 Not sure actually what our requirements strategy is for bears^^

end_line=2,
end_column=20,
severity=RESULT_SEVERITY.INFO)],
filename=get_testfile_path(filename),

This comment has been minimized.

@Makman2

Makman2 Jul 5, 2017
Member

you should also check good files 👍

This comment has been minimized.

@yash-nisar

yash-nisar Jul 6, 2017
Author Member

Done 👍

@Makman2
Copy link
Member

@Makman2 Makman2 commented Jul 5, 2017

You could write into the commit message body that part of the fixing was to improve the tests.

@yash-nisar yash-nisar force-pushed the yash-nisar:rubocop-investigation branch 3 times, most recently from e1139dc to 2359913 Jul 6, 2017
@yash-nisar
Copy link
Member Author

@yash-nisar yash-nisar commented Jul 6, 2017

Updated @Makman2

settings={'indent_size': 1})

def test_good_indent_size(self):
filename = 'bad_indent_file.rb'

This comment has been minimized.

@Makman2

Makman2 Jul 6, 2017
Member

maybe just call the file indent.rb, as in this context it isn't bad?

@yash-nisar yash-nisar force-pushed the yash-nisar:rubocop-investigation branch from 2359913 to 51507c5 Jul 6, 2017
@Makman2
Copy link
Member

@Makman2 Makman2 commented Jul 6, 2017

ack 51507c5

rubocop-hq/rubocop#4226 indicates that `--stdin`
takes filename as an argument which was incorporated. A part of the
fixing was to improve the tests that involved the bear to be run on
files with the `.rb`(ruby) extension because initially the bear was
run on the generated temporary files that was the cause of error.

Fixes #1548
@yash-nisar yash-nisar force-pushed the yash-nisar:rubocop-investigation branch from 51507c5 to d35b120 Jul 6, 2017
@Makman2
Copy link
Member

@Makman2 Makman2 commented Jul 6, 2017

reack d35b120

@Makman2
Copy link
Member

@Makman2 Makman2 commented Jul 6, 2017

@rultor merge

@rultor
Copy link

@rultor rultor commented Jul 6, 2017

@rultor merge

@Makman2 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit d35b120 into coala:master Jul 6, 2017
6 of 9 checks passed
6 of 9 checks passed
ci/circleci CircleCI is running your tests
Details
continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
codecov/project 100% (target 100%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
review/gitmate/commit No issues with this one - go ahead! :)
Details
review/gitmate/manual This commit was acknowledged.
Details
review/gitmate/pr All is well! :) (0 problems solved)
Details
@rultor
Copy link

@rultor rultor commented Jul 6, 2017

@rultor merge

@Makman2 Done! FYI, the full log is here (took me 2min)

@yash-nisar yash-nisar deleted the yash-nisar:rubocop-investigation branch Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.