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

Add MarkdownfmtBear #1896

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

Add MarkdownfmtBear #1896

wants to merge 1 commit into from

Conversation

naveentata
Copy link
Contributor

It suggests better formatting in markdown files.

Closes #1538

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!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

Copy link
Contributor

@NiklasMM NiklasMM left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. I think this is a great addition to coala.

Since your Bear can suggest patches for the issues it identifies, I'd ask you to add tests for that too. You can check out the tests for other Bears, e.g. PyImportSortBearTests to find out how that's done.

If you need help feel free to ask here or on Gitter.


For more information visit
<https://github.com/shurcooL/markdownfmt>
Note that MarkdownfmtBear works with pure Markdown files
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean "only with pure Markdown files"? If so, please add the word "only" for more clarity.

valid_files=(spacing_in_file2,),
invalid_files=(spacing_out_file2,),
settings={'checks_for_spacing' : 'true'})

Copy link
Collaborator

Choose a reason for hiding this comment

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

W391 blank line at end of file'

PycodestyleBear (W391), severity NORMAL, section autopep8.

MarkdownfmtBear,
valid_files=(spacing_in_file2,),
invalid_files=(spacing_out_file2,),
settings={'checks_for_spacing' : 'true'})
Copy link
Collaborator

Choose a reason for hiding this comment

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

E203 whitespace before ':''

PycodestyleBear (E203), severity NORMAL, section autopep8.

MarkdownfmtBear,
valid_files=(header_in_file1,),
invalid_files=(header_out_file1,),
settings={'checks_for_headers' : 'true'})
Copy link
Collaborator

Choose a reason for hiding this comment

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

E203 whitespace before ':''

PycodestyleBear (E203), severity NORMAL, section autopep8.


"""

spacing_out_file2="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

E225 missing whitespace around operator'

PycodestyleBear (E225), severity NORMAL, section autopep8.


"""

spacing_in_file2="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

E225 missing whitespace around operator'

PycodestyleBear (E225), severity NORMAL, section autopep8.


"""

header_out_file1="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

E225 missing whitespace around operator'

PycodestyleBear (E225), severity NORMAL, section autopep8.

from coalib.testing.LocalBearTestHelper import verify_local_bear


header_in_file1="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

E225 missing whitespace around operator'

PycodestyleBear (E225), severity NORMAL, section autopep8.

MarkdownfmtBear,
valid_files=(spacing_in_file2,),
invalid_files=(spacing_out_file2,),
settings={'checks_for_spacing' : 'true'})
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -37,5 +37,4 @@
     MarkdownfmtBear,
     valid_files=(spacing_in_file2,),
     invalid_files=(spacing_out_file2,),
-    settings={'checks_for_spacing' : 'true'})
-
+    settings={'checks_for_spacing': 'true'})

MarkdownfmtBear,
valid_files=(header_in_file1,),
invalid_files=(header_out_file1,),
settings={'checks_for_headers' : 'true'})
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -30,7 +30,7 @@
     MarkdownfmtBear,
     valid_files=(header_in_file1,),
     invalid_files=(header_out_file1,),
-    settings={'checks_for_headers' : 'true'})
+    settings={'checks_for_headers': 'true'})
 
 
 MarkdownfmtBear = verify_local_bear(


"""

spacing_out_file2="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -20,7 +20,7 @@
 
 """
 
-spacing_out_file2="""
+spacing_out_file2 = """
 
 This is a test file.
 


"""

spacing_in_file2="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -14,7 +14,7 @@
 
 """
 
-spacing_in_file2="""
+spacing_in_file2 = """
 
 This is   a test    file.
 


"""

header_out_file1="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -8,7 +8,7 @@
 
 """
 
-header_out_file1="""
+header_out_file1 = """
 MarkdownBear
 ============
 

from coalib.testing.LocalBearTestHelper import verify_local_bear


header_in_file1="""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/tests/markdown/MarkdownfmtBearTest.py
+++ b/tests/markdown/MarkdownfmtBearTest.py
@@ -2,7 +2,7 @@
 from coalib.testing.LocalBearTestHelper import verify_local_bear
 
 
-header_in_file1="""
+header_in_file1 = """
 MarkdownBear
 =====
 

@naveentata naveentata force-pushed the test branch 2 times, most recently from 87d1646 to e23d751 Compare July 17, 2017 12:47
like alignment, indendation are provided.

For more information visit
<https://github.com/shurcooL/markdownfmt>
Copy link
Member

Choose a reason for hiding this comment

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

Add this in the SEE_MORE attribute.


@staticmethod
def create_arguments(filename, file, config_file):
return()
Copy link
Member

Choose a reason for hiding this comment

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

So we use stdin for the input and not the filename ?

@@ -0,0 +1,37 @@
from bears.markdown.MarkdownfmtBear import MarkdownfmtBear
from coalib.testing.LocalBearTestHelper import verify_local_bear

Copy link
Member

Choose a reason for hiding this comment

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

Imports should be in the following order: (Note that I've left a line)

from coalib.testing.LocalBearTestHelper import verify_local_bear

from bears.markdown.MarkdownfmtBear import MarkdownfmtBear

like alignment, indendation are provided.

For more information visit
<https://github.com/shurcooL/markdownfmt>
Copy link
Member

Choose a reason for hiding this comment

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

move this to SEE_MORE


@staticmethod
def create_arguments(filename, file, config_file):
return()
Copy link
Member

Choose a reason for hiding this comment

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

return list() just a preference though 😅


For more information visit
<https://github.com/shurcooL/markdownfmt>
Note that MarkdownfmtBear works only with pure Markdown files
Copy link
Member

Choose a reason for hiding this comment

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

clearly explain what you mean by "pure Markdown files"

Copy link
Member

Choose a reason for hiding this comment

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

Missing period.

use_stderr=True)
class MarkdownfmtBear:
"""
Suggests better formatting in Markdown files. Basic checks
Copy link
Member

Choose a reason for hiding this comment

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

how about:

Check and correct formatting of Markdown files using ``mardownfmt``.

MarkdownfmtBear = verify_local_bear(
MarkdownfmtBear,
valid_files=(spacing_in_file2,),
invalid_files=(spacing_out_file2,))
Copy link
Member

Choose a reason for hiding this comment

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

You need to improve your tests 😉 . You can refer to any bear with code correcting capabilities. (e.g. MarkdownBear)

LICENSE = 'AGPL-3.0'
CAN_FIX = {'Formatting'}
ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
SEE_MORE = 'https://github.com/shurcooL/markdownfmt'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

SpaceConsistencyBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/bears/markdown/MarkdownfmtBear.py
+++ b/bears/markdown/MarkdownfmtBear.py
@@ -21,7 +21,7 @@
     LICENSE = 'AGPL-3.0'
     CAN_FIX = {'Formatting'}
     ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
-    SEE_MORE = 'https://github.com/shurcooL/markdownfmt' 
+    SEE_MORE = 'https://github.com/shurcooL/markdownfmt'
 
     @staticmethod
     def create_arguments(filename, file, config_file):

"""
Check and correct formatting of Markdown files using ``mardownfmt``.
Basic checks like alignment, indendation are provided.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

SpaceConsistencyBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/bears/markdown/MarkdownfmtBear.py
+++ b/bears/markdown/MarkdownfmtBear.py
@@ -10,7 +10,7 @@
     """
     Check and correct formatting of Markdown files using ``mardownfmt``.
     Basic checks like alignment, indendation are provided.
-    
+
     Note that MarkdownfmtBear works only with pure Markdown files.
     """
     LANGUAGES = {'Markdown'}

LICENSE = 'AGPL-3.0'
CAN_FIX = {'Formatting'}
ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
SEE_MORE = 'https://github.com/shurcooL/markdownfmt'
Copy link
Collaborator

Choose a reason for hiding this comment

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

W291 trailing whitespace'

PycodestyleBear (W291), severity NORMAL, section autopep8.

"""
Check and correct formatting of Markdown files using ``mardownfmt``.
Basic checks like alignment, indendation are provided.

Copy link
Collaborator

Choose a reason for hiding this comment

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

W293 blank line contains whitespace'

PycodestyleBear (W293), severity NORMAL, section autopep8.

LICENSE = 'AGPL-3.0'
CAN_FIX = {'Formatting'}
ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
SEE_MORE = 'https://github.com/shurcooL/markdownfmt'
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/bears/markdown/MarkdownfmtBear.py
+++ b/bears/markdown/MarkdownfmtBear.py
@@ -21,7 +21,7 @@
     LICENSE = 'AGPL-3.0'
     CAN_FIX = {'Formatting'}
     ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
-    SEE_MORE = 'https://github.com/shurcooL/markdownfmt' 
+    SEE_MORE = 'https://github.com/shurcooL/markdownfmt'
 
     @staticmethod
     def create_arguments(filename, file, config_file):

"""
Check and correct formatting of Markdown files using ``mardownfmt``.
Basic checks like alignment, indendation are provided.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

PEP8Bear, severity NORMAL, section autopep8.

The issue can be fixed by applying the following patch:

--- a/bears/markdown/MarkdownfmtBear.py
+++ b/bears/markdown/MarkdownfmtBear.py
@@ -10,7 +10,7 @@
     """
     Check and correct formatting of Markdown files using ``mardownfmt``.
     Basic checks like alignment, indendation are provided.
-    
+
     Note that MarkdownfmtBear works only with pure Markdown files.
     """
     LANGUAGES = {'Markdown'}

Check and correct formatting of Markdown files using ``mardownfmt``.
Basic checks like alignment, indendation are provided.

Note that MarkdownfmtBear works only with pure Markdown files.
Copy link
Member

Choose a reason for hiding this comment

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

is it still not clear what you mean by pure Markdown files

@AsnelChristian
Copy link
Member

you should fix gitmate issues

from coalib.testing.LocalBearTestHelper import verify_local_bear

from bears.markdown.MarkdownfmtBear import MarkdownfmtBear

Copy link
Member

Choose a reason for hiding this comment

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

We leave 2 lines before the code begins.

@yash-nisar
Copy link
Member

yash-nisar commented Jul 21, 2017

Your tests seem to be failing. Can you fix and improve them if possible ?

It suggests better formatting in markdown files.

Closes coala#1538
@meetmangukiya
Copy link
Member

meetmangukiya commented Jul 22, 2017

@naveentata please fix your tests

@naveentata
Copy link
Contributor Author

@meetmangukiya I am not able to figure out what is wrong in the test, can you please help me? 😟

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.

bear proposal https://github.com/shurcooL/markdownfmt
8 participants