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

DartLintBear: check settings validity #950

Merged
merged 1 commit into from
Oct 30, 2016
Merged

DartLintBear: check settings validity #950

merged 1 commit into from
Oct 30, 2016

Conversation

NiklasMM
Copy link
Contributor

As pointed out here dart-lang/dart_style#261
dartanalyzer only supports indentation using 2 spaces. This commit
changes DartLintBear to check that use_spaces is True and
indent_size is 2 and raises a ValueError if not.

Fixes #897

@gitmate-bot
Copy link
Collaborator

Thanks for your contribution!

Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.

As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well!

@Adrianzatreanu
Copy link
Contributor

apparently this fails because it is not rebased, and does not contain the changes you fixed in the other branch. could you rebase it and i think all will pass :D ? thanks!

@NiklasMM
Copy link
Contributor Author

Yeah, will do this tomorrow... My stupid hotel only allows HTTP(S) traffic =(


# use_spaces must be True and indent_size must be 2 because
# dartanalyzer only supports these settings
# see https://github.com/dart-lang/dart_style/issues/261
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting the link here ! Really appreciated :)

section.append(Setting('use_spaces', False))
bear = DartLintBear(section, Queue())

with pytest.raises(AssertionError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use unittest's assertRaises ? https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises

It has the same functionality (The reason I mention is because it's nicer to use the builtin unittest as much as possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, since py.test is used as a test runner, I thought it best to use it directly as much as possible. But if it serves the uniformity of the code base, I'll change it ;)

@@ -30,3 +37,23 @@
valid_files=(good_file,),
invalid_files=(bad_file,),
tempfile_kwargs={"suffix": ".dart"})


@skipIf(which('dartanalyzer') is None, 'dartanalyzer is not installed')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't write your custom check please !
Use the skip generator for the bear ? https://github.com/coala/coala-bears/blob/master/tests/BearTestHelper.py#L4

@NiklasMM
Copy link
Contributor Author

@AbdealiJK Thanks for the review! I made the requested changes.

# see https://github.com/dart-lang/dart_style/issues/261
if (indent_size != 2 or not use_spaces):
raise ValueError(
"dartanazlyer only supports use_space=True and indent_size=2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: dartanalyzer here :)

# see https://github.com/dart-lang/dart_style/issues/261
if (indent_size != 2 or not use_spaces):
raise ValueError(
"dartanazlyer only supports use_space=True and indent_size=2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, an user probably doesnt know what dartanalyzer is, as we are wrapping it into a bear, im not 100% percent, but maybe we should say:
DartLintBear only supports.. ? what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

bear = DartLintBear(section, Queue())

with self.assertRaises(AssertionError):
self.check_validity(bear, [], good_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests are actually nice work :)

@AbdealiLoKo
Copy link
Contributor

@NiklasMM Nearly there. Just a few minor things and a rebase

# see https://github.com/dart-lang/dart_style/issues/261
if (indent_size != 2 or not use_spaces):
raise ValueError(
"DartLintBear only supports use_space=True and indent_size=2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_space -> use_spaces, I'd also put the "ini extracts" in backticks

As pointed out here dart-lang/dart_style#261,
dartanalyzer only supports indentation using 2 spaces. This commit
changes DartLintBear to check that ``use_spaces`` is True and
``indent_size`` is 2 and raises a ``ValueError`` if not.

Fixes #897
@sils
Copy link
Member

sils commented Oct 30, 2016

907b477 is ready

@sils sils dismissed AbdealiLoKo’s stale review October 30, 2016 13:31

changes have been addressed

@sils
Copy link
Member

sils commented Oct 30, 2016

@rultor merge

@sils
Copy link
Member

sils commented Oct 30, 2016

Hey, this is your first contribution, right? Congrats and welcome to the coalaians! :)

You can help us a lot by filling out http://coala.io/newform!

Rultor will now automatically release your changes as a prerelease so users can experience the goodness of your changes right now.

See also https://github.com/coala-analyzer/coala/wiki/coala-Steam-Offer btw.

We would really appreciate it if you could help us with

  • some code reviews for other newcomers
  • fixing at least a difficulty/low issue

We're all volunteers and we're currently struggling to keep this up. Helping all those newcomers is a lot of work and we do need your help so we can continue this for others!

@rultor
Copy link

rultor commented Oct 30, 2016

@rultor merge

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

@rultor rultor merged commit 907b477 into coala:master Oct 30, 2016
@rultor
Copy link

rultor commented Oct 30, 2016

@rultor merge

@sils Done! FYI, the full log is here (took me 1min)

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

Successfully merging this pull request may close these issues.

6 participants