-
Notifications
You must be signed in to change notification settings - Fork 1
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
[#4044] Add semantic newline checker in lint #7
base: master
Are you sure you want to change the base?
Changes from 2 commits
797ac80
24c7424
fd6e712
133044a
a903fe4
031b4ad
75252ec
cd9554a
4a3f949
3fad50a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,14 @@ | |
|
||
|
||
-------------------- | ||
Second emtpy section | ||
Second empty section | ||
-------------------- | ||
|
||
|
||
Third section | ||
^^^^^^^^^^^^^ | ||
|
||
Paragrhap for | ||
Paragraph for | ||
third section `with link<http://my.home>`_. | ||
|
||
:: | ||
|
@@ -44,6 +44,13 @@ | |
| verse, and adornment-free lists. | ||
|
||
|
||
Newline test! No newline. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this data is called but, you have introduced invalid content here, yet no test using this data was updated. Something is not right here. check_semantic_newline is not actually used. I think that it should be defined in the RST checker and enabled there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's not really clear to me what this section does. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That data is used in test_valid_content. As described in the comment, it is not placed closed to test_valid_content, but rather at the top to make it easier to debug the test Is ok to update the content of this data. but it should be updated only with valid data. this is a regression test to check that we don't have false-positives |
||
Newline test? No newline. | ||
Newline test. No newline. | ||
Newline test has newline. | ||
Indeed. | ||
|
||
|
||
.. _section-permalink: | ||
|
||
Another Section with predefined link | ||
|
@@ -141,7 +148,7 @@ def test_no_empty_last_line(self): | |
self.reporter.call_count = 0 | ||
content = ( | ||
'Some first line\n' | ||
'the second and last line witout newline') | ||
'the second and last line without newline') | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_empty_last_line(2) | ||
expected = [( | ||
|
@@ -343,6 +350,78 @@ def test_check_section_delimiter_bad_marker_length(self): | |
self.assertEqual(expect, self.reporter.messages) | ||
self.assertEqual(1, self.reporter.call_count) | ||
|
||
def test_semantic_newline_fullstop(self): | ||
"""When a full stop is not the last character of the line, it is | ||
considered a semantic newline violation and an error is reported.""" | ||
content = ( | ||
'Sentence. New sentence\n' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code from The design should be that The tests should use instead the base |
||
expect = ['Newline not created after a sentence.'] | ||
self.assertEqual(expect, self.reporter.messages) | ||
self.assertEqual(1, self.reporter.call_count) | ||
|
||
def test_semantic_newline_fullstop_true(self): | ||
"""When a full stop is the last character from the line and follows the | ||
semantic newline rule, an error is not reported.""" | ||
content = ( | ||
'Sentence. \n' | ||
'New sentence.' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
self.assertEqual([], self.reporter.messages) | ||
self.assertEqual(0, self.reporter.call_count) | ||
|
||
def test_semantic_newline_questionmark(self): | ||
"""When a question mark is not the last character of the line, it is | ||
considered a semantic newline violation and an error is reported.""" | ||
content = ( | ||
'Sentence? New sentence\n' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
expect = [('Newline not created after a ? sentence.')] | ||
self.assertEqual(expect, self.reporter.messages) | ||
self.assertEqual(1, self.reporter.call_count) | ||
|
||
def test_semantic_newline_questionmark_true(self): | ||
"""When a question mark is the last character from the line and follows | ||
semantic newline rule, an error is not reported.""" | ||
content = ( | ||
'Sentence? \n' | ||
'New sentence\n' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
self.assertEqual([], self.reporter.messages) | ||
self.assertEqual(0, self.reporter.call_count) | ||
|
||
def test_semantic_newline_exclamationmark(self): | ||
"""When an exclamation mark is not the last character of the line, it | ||
is considered a semantic newline violation and an error is reported.""" | ||
content = ( | ||
'Sentence! New sentence\n' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
expect = [('Newline not created after a ! sentence.')] | ||
self.assertEqual(expect, self.reporter.messages) | ||
self.assertEqual(1, self.reporter.call_count) | ||
|
||
def test_semantic_newline_exclamationmark_true(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what to say about all these tests. I feel like there is a lot of duplication in these tests. So maybe just have a single test in which the content is
|
||
"""When an exclamation mark is the last character from the line and | ||
follows the semantic newline rule, an error is not reported.""" | ||
content = ( | ||
'Sentence! \n' | ||
'New sentence\n' | ||
) | ||
checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
checker.check_semantic_newline() | ||
self.assertEqual([], self.reporter.messages) | ||
self.assertEqual(0, self.reporter.call_count) | ||
|
||
def test_check_section_delimiter_bad_length_both_markers(self): | ||
content = ( | ||
'---------\n' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is defined here, but is not 'enabled' in any checkers.
also, since for now we plan to use it only for RST it should be moved into the RST checker.