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

MarkdownBear: Add validate-links plugin #1919

Merged
merged 5 commits into from Jul 18, 2017

Conversation

yash-nisar
Copy link
Member

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

Closes #924

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


args += ['--use', 'validate-links']
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we have an option for this?

Copy link
Member

Choose a reason for hiding this comment

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

orientate on our InvalidLinksBear regarding setting names 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@Makman2 Our InvalidLinkBear has no such setting. I've also checked the UrlBear on which the former bear depends. 😉

Copy link
Member

Choose a reason for hiding this comment

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

Yeah if you enable InvalidLinkBear you definitely want to check invalid links :) In this case this should be optional 👍 Internet accesses aren't always desired by people that want to lint their code 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

No No, I meant I've checked the InvalidLinkBear for a similar setting name. Is the PR good ?

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
LICENSE = 'AGPL-3.0'
CAN_FIX = {'Formatting'}

_output_regex = re.compile(
r'\s*(?P<line>\d+):(?P<column>\d+)'
r'\s*(?P<severity>warning)\s*(?P<message>.*)')
r'\s*(?P<severity>warning)\s*(?P<message>.+?)(?: .*|\n|$)')
Copy link
Member

Choose a reason for hiding this comment

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

is this maybe a separate commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure 👍

@@ -127,22 +128,23 @@ def create_arguments(filename, file, config_file,
'ruleSpaces': horizontal_rule_spaces, # Bool
'ruleRepetition': horizontal_rule_repeat, # int
}
remark_configs_plugins = {}
remark_lint_configs = {}
Copy link
Member

Choose a reason for hiding this comment

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

the rename should be a separate commit

@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 16, 2017

@Makman2 @sils How does it look now ?

@@ -108,6 +110,9 @@ def create_arguments(filename, file, config_file,
The number of times the horizontal rule character will be repeated.
:param max_line_length:
The maximum line length allowed.
:param check_valid_links:
Checks if links to headings and files in markdown point to
existing things.
Copy link
Member

Choose a reason for hiding this comment

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

Hmm that kinda sounds weird :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed 👍

@@ -65,7 +66,8 @@ def create_arguments(filename, file, config_file,
horizontal_rule: str='*',
horizontal_rule_spaces: bool=False,
horizontal_rule_repeat: int=3,
max_line_length: int=None):
max_line_length: int=None,
check_valid_links: bool=None):
Copy link
Member

Choose a reason for hiding this comment

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

Use False instead of None, we don't need a tri-state for this field.

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 👍

@@ -136,13 +141,16 @@ def create_arguments(filename, file, config_file,
# Remove { and } as remark adds them on its own
settings = config_json[1:-1]

args = ['--no-color', '--quiet', '--setting', settings]
args = [filename, '--no-color', '--quiet', '--setting', settings]
Copy link
Member

Choose a reason for hiding this comment

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

do you really need filename, as the linter has use_stdin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, use_stdin doesn't work with validate-links 😄 I've removed the use_stdin though 👍

Copy link
Member

@Makman2 Makman2 Jul 18, 2017

Choose a reason for hiding this comment

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

Ah write that into the commit message please :D
(the reason why you remove use_stdin)

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 👍

@@ -50,7 +50,7 @@


@generate_skip_decorator(MarkdownBear)
class MarkdownBearMaxLineLengthMessageTest(unittest.TestCase):
class MarkdownBearTest(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

for me it's obvious, anyway put the reason into the commit message :)

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 👍

@@ -30,7 +30,7 @@ class MarkdownBear:

_output_regex = re.compile(
r'\s*(?P<line>\d+):(?P<column>\d+)'
r'\s*(?P<severity>warning)\s*(?P<message>.*)')
r'\s*(?P<severity>warning)\s*(?P<message>.+?)(?: .*|\n|$)')
Copy link
Member

Choose a reason for hiding this comment

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

Please reason that inside the commit message :)

Copy link
Member

Choose a reason for hiding this comment

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

Actually I would rephrase the shortlog to something like Improve result message or so, as this is the effective reason :)

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 👍


if max_line_length:
remark_configs_plugins['maximumLineLength'] = max_line_length
remark_lint_configs['maximumLineLength'] = max_line_length

config_json = json.dumps(remark_configs_settings)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should also rename this to remark_configs, so it's easier to distinct from remark_lint_configs?

Up to you 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

One more commit ?

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, added a commit stating the same 👍

@AsnelChristian
Copy link
Member

please rebase and address @Makman2 issues :)

@yash-nisar
Copy link
Member Author

Updated @Makman2

@@ -65,7 +65,8 @@ def create_arguments(filename, file, config_file,
horizontal_rule: str='*',
horizontal_rule_spaces: bool=False,
horizontal_rule_repeat: int=3,
max_line_length: int=None):
max_line_length: int=None,
check_valid_links: bool=False):
Copy link
Member

Choose a reason for hiding this comment

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

maybe just check_links? Strictly: As only checking valid links won't yield any results, as those are valid, right? ;)

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 👍

@Makman2
Copy link
Member

Makman2 commented Jul 18, 2017

For the rename commits: Please put the reason of the name-change into the commit body 👍

Add `validate-links` plugin and since the `validate-links`
plugin is incompatible with stdin input, `use_stdin=True`
was removed.

Closes coala#924
Rename test classname from `MarkdownBearMaxLineLengthMessageTest`
to `MarkdownBearTest` because there were a few generic additions
to the tests.
Rename `remark_configs_plugins` to `remark_lint_configs` because
the latter is more appropriate and future addition of plugins
may conflict with the former name.
Improves the result message by modifying the regex and ignoring
the non-crucial output obtained from the linter.
Rename to `remark_configs` so it becomes easier to distinguish
from `remark_lint_configs`.
@Makman2
Copy link
Member

Makman2 commented Jul 18, 2017

ack f68bd91 2a21048 d83fe5f 71f6bc5 d6100ce

@Makman2
Copy link
Member

Makman2 commented Jul 18, 2017

@rultor merge

@rultor
Copy link

rultor commented Jul 18, 2017

@rultor merge

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

@rultor rultor merged commit d6100ce into coala:master Jul 18, 2017
@rultor
Copy link

rultor commented Jul 18, 2017

@rultor merge

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

@yash-nisar yash-nisar deleted the md-validate-links branch July 18, 2017 17:32
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.

MarkdownBear: Add remark-validate-links plugin
7 participants