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

bears/pug: Add PugLintBear #1936

Merged
merged 1 commit into from Jul 21, 2017
Merged

bears/pug: Add PugLintBear #1936

merged 1 commit into from Jul 21, 2017

Conversation

yash-nisar
Copy link
Member

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

Closes #290

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!

@yash-nisar
Copy link
Member Author

CC @Makman2

def process_output(self, output, filename, file):
stdout, stderr = output
yield from self.process_output_regex(stderr, filename, file,
self._output_regex)
Copy link
Member

Choose a reason for hiding this comment

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

why you don't use output_format=regex?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 🎉

div


div
Copy link
Member

Choose a reason for hiding this comment

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

are the missing \n at EOF on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, my bad.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. 👍

use_stderr=True)
class PugLintBear:
"""
A configurable linter and style checker for Pug (formerly Jade) that is a
Copy link
Member

Choose a reason for hiding this comment

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

"""Pug"'' (formerly "jade"

Copy link
Member

Choose a reason for hiding this comment

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

enclose them within backsticks

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

validate_extensions: bool=True,
validate_self_closing_tags: bool=True,
preferred_quotation: str='\'',
max_lines_per_file: int=None,
Copy link
Member

Choose a reason for hiding this comment

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

change max_lines_per_file -> max_file_length, for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have named the setting as max_lines_per_file in LineCountBear, so I think we should keep max_lines_per_file for consistency of the settings throughout.

Copy link
Member

Choose a reason for hiding this comment

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

there is the TailorBear that has max_file_length

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we open an issue for that ?

Copy link
Member

Choose a reason for hiding this comment

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

@Makman2 , @yash-nisar let's vote 😄 and get rid of the other setting
i am for using max_file_length as we have max_line_length

Copy link
Member Author

Choose a reason for hiding this comment

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

Nvm, doing so right away 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Haha okay, lets vote 👍

Copy link
Member

Choose a reason for hiding this comment

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

max_file_length might refer to the number of chars inside a document, max_lines_per_file is less ambigious^^ So imo max_lines_per_file is better 👍

For example: If set to ``True``, prefer
``input(type='text').class`` over ``input.class(type='text')``.
:param prohibit_class_literals_before_id_literals:
When ``True``, prefer all ID literals to be written before any
Copy link
Member

Choose a reason for hiding this comment

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

^^

When ``True``, all attributes should be written in lower case.
For example: If set to ``True``, prefer ``div(class='class')``
over ``div(Class='class')``.
:param require_lower_case_tags:
Copy link
Member

Choose a reason for hiding this comment

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

enforce_lower_case_tags

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

When ``True``, all tags must be written in lower case.
For example: If set to ``True``, prefer ``div(class='class')``
over ``Div(class='class')``.
:param require_spaces_inside_attribute_brackets:
Copy link
Member

Choose a reason for hiding this comment

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

enforce_spaces_inside_attribute_brackets

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

:param require_spaces_inside_attribute_brackets:
When ``True``, enforce space after opening attribute bracket and
before closing attribute bracket.
:param require_strict_equality_operators:
Copy link
Member

Choose a reason for hiding this comment

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

enforce_...

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

@yash-nisar
Copy link
Member Author

Updated @Makman2

validate_div_tags: bool=True,
validate_extensions: bool=True,
validate_self_closing_tags: bool=True,
preferred_quotation: str='\'',
Copy link
Member

Choose a reason for hiding this comment

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

use "'" instead of '\''

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

When ``True``, prefer all attribute blocks to be written before
any class literals.
For example: If set to ``True``, prefer
``input(type='text').class`` over ``input.class(type='text')``.
Copy link
Member

Choose a reason for hiding this comment

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

what's with enforcing the other way around?

def create_arguments(filename, file, config_file, puglint_config: str=''):
"""
:param puglint_config:
The location of the ``.pug-lintrc`` config file.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe

The location of a custom  ``.pug-lintrc`` config file.

So it doesn't sound that this parameter is mandatory?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good 👍

"requireClassLiteralsBeforeIdLiterals":false,
"validateDivTags":true,
"disallowTagInterpolation":true
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, eof damnit.

@yash-nisar yash-nisar force-pushed the pug-bear branch 2 times, most recently from 763e01b to d41309b Compare July 18, 2017 17:34
enforce_lower_case_attributes: bool=True,
enforce_lower_case_tags: bool=True,
require_spaces_inside_attribute_brackets: bool=False,
require_strict_equality_operators: bool=True,
Copy link
Member

Choose a reason for hiding this comment

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

what's with these using enforce as prefix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I'll use it for them too 👍

@AsnelChristian
Copy link
Member

AsnelChristian commented Jul 18, 2017 via email

@AsnelChristian
Copy link
Member

AsnelChristian commented Jul 18, 2017 via email

``input.class#id(type='text')``.
:param prohibit_class_literals:
When ``True``, disallow any class literals.
For example: If set to ``True``, prefer ``div(class='class')``
Copy link
Member

Choose a reason for hiding this comment

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

i am kind of lost prohibit_class_attribute_with_static_value default value is True so you make use of class literals but here prohibit_class_literals you prohibit them.... isn't that contradicting?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 👍

@yash-nisar
Copy link
Member Author

One weird thing that I noticed was that the config (which is later converted to json) only takes the values true and null, so I've made the required changes.

@yash-nisar
Copy link
Member Author

CC @Makman2 @AsnelChristian

options = {
'disallowBlockExpansion':
prohibit_block_expansion if prohibit_block_expansion
else None,
Copy link
Member

Choose a reason for hiding this comment

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

can you maybe loop over the dict and assign None for each entry if needed?

options = {...}
for k, v in options.items():
    options[k] = v if v else None

Copy link
Member

Choose a reason for hiding this comment

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

or write a little function like map_bool()

Copy link
Member Author

Choose a reason for hiding this comment

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

I had initially done a settings_map where I mapped False to None

@yash-nisar
Copy link
Member Author

@Makman2 Updated.

@AsnelChristian
Copy link
Member

👍

@AsnelChristian
Copy link
Member

ack 4cfe907

@AsnelChristian
Copy link
Member

@Makman2 ping! 😄

@Makman2
Copy link
Member

Makman2 commented Jul 20, 2017

@AsnelChristian bam! 💥
thanks for reviewing :D
rebase and lgtm @yash-nisar :)

@yash-nisar
Copy link
Member Author

reack 1d31827

@sils
Copy link
Member

sils commented Jul 21, 2017

@rultor merge

@rultor
Copy link

rultor commented Jul 21, 2017

@rultor merge

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

@rultor rultor merged commit 1d31827 into coala:master Jul 21, 2017
@yash-nisar yash-nisar deleted the pug-bear branch July 21, 2017 07:20
@rultor
Copy link

rultor commented Jul 21, 2017

@rultor merge

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

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.

Pug Bear
8 participants