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

LatexLintBear.py: Fix formatting error #2399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

damian1996
Copy link
Contributor

@damian1996 damian1996 commented Apr 1, 2018

This removes the extra !n from the messages generated
by LatexLintBear and add a test to check it.

Fixes #1876

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!

@@ -17,3 +21,15 @@
LatexLintBearTest = verify_local_bear(LatexLintBear,
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you put it inside LatexBearTest class? 😉 Then you don't need to import verify_local_bear anymore.

@damian1996 damian1996 force-pushed the FixLatexFormattingError branch from 0e66d7b to d4111fb Compare April 2, 2018 13:42
from coalib.testing.LocalBearTestHelper import verify_local_bear
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper
from coalib.testing.BearTestHelper import generate_skip_decorator
from bears.latex.LatexLintBear import LatexLintBear
Copy link
Member

Choose a reason for hiding this comment

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

Generally, we keep all these in alphabetical order.

This removes the extra !n from the messages generated
by LatexLintBear and add a test to check it.

Fixes coala#1876
@damian1996 damian1996 force-pushed the FixLatexFormattingError branch from d4111fb to f06a8a3 Compare April 2, 2018 15:15
self.check_validity(self.uut, ['{.}', '{ sometext }'])
self.check_invalidity(self.uut, ['{ .}', '{ sometext }'])
results = self.check_invalidity(self.uut, ['2018-12-01'])
self.assertEqual('Wrong length of dash may have been used.',
Copy link
Member

@sangamcse sangamcse Apr 2, 2018

Choose a reason for hiding this comment

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

Do we need this? IMO, check_invalidity(...) can detect if it is giving any type of error message. So, don't need to use assertEqual(...) here.
Check second last line here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sangamcse I wanted to test result, which show that I properly corrected bug from issue (This was mentioned in issue).

Copy link
Member

Choose a reason for hiding this comment

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

Oh. But this message is not matching with the --format given in create_arguments(...). Am I missing something? 😃

Copy link
Member

Choose a reason for hiding this comment

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

Ohk. Got it. NM 😅

Copy link
Member

Choose a reason for hiding this comment

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

As this was about a newline marker, which is mostly needed if there are multiple errors/warnings/etc, please add a test where there are two messages emitted by chktex, and verify both messages are correctly extracted from the output.

Copy link
Contributor Author

@damian1996 damian1996 Apr 6, 2018

Choose a reason for hiding this comment

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

@jayvdb I have following problem : When I created such file to test as below, then only first error was passed to messages in results. I saw the same behaviour when I run coala -b LatexLintBear --files=test.tex on actual version available for user.

2018-12-01
Let $t\in[0,\infty)$.

In my opinion here should be two messages : "Wrong length of dash may have been used." and "Number of [' doesn't match the number of ]'!"

Copy link
Member

@sangamcse sangamcse left a comment

Choose a reason for hiding this comment

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

LGTM 😄
cc @Makman2

@@ -22,6 +22,6 @@ class LatexLintBear:
def create_arguments(filename, file, config_file):
return (
'--format',
'%k %n in {0} line %l: %m!n'.format(filename),
'%k %n in {0} line %l: %m'.format(filename),
Copy link
Member

Choose a reason for hiding this comment

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

hmm. the !n was added by me while fixing #317

It translates to newline, but I am not 100% sure it was necessary.

Copy link
Member

Choose a reason for hiding this comment

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

Ya, !n isnt working.

Another approach is to use -v0

self.check_validity(self.uut, ['{.}', '{ sometext }'])
self.check_invalidity(self.uut, ['{ .}', '{ sometext }'])
results = self.check_invalidity(self.uut, ['2018-12-01'])
self.assertEqual('Wrong length of dash may have been used.',
Copy link
Member

Choose a reason for hiding this comment

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

As this was about a newline marker, which is mostly needed if there are multiple errors/warnings/etc, please add a test where there are two messages emitted by chktex, and verify both messages are correctly extracted from the output.

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.

LatexLintBear: Format error
4 participants