-
Notifications
You must be signed in to change notification settings - Fork 1
[#4044] Add semantic newline checker in lint #7
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
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ | ||
| Keeps the version of the project. | ||
| """ | ||
| VERSION = '0.3.1' | ||
| VERSION = '0.3.4' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,6 @@ | |
| | verse, and adornment-free lists. | ||
|
|
||
|
|
||
| Newline test! No newline. | ||
| Newline test? No newline. | ||
| Newline test. No newline. | ||
| Newline test has newline. | ||
| Indeed. | ||
|
|
||
|
|
@@ -350,29 +347,31 @@ 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 | ||
| def test_semantic_newline_alltests_true(self): | ||
| """When a ., ?, or ! 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' | ||
| 'Sentence. \n' | ||
|
Member
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 test is wrong...as it will trigger the "trailing newspaces" checker |
||
| 'Sentence! \n' | ||
| 'Sentence? \n' | ||
| ) | ||
| checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
| checker.check_semantic_newline() | ||
| expect = ['Newline not created after a sentence.'] | ||
| checker._check_semantic_newline() | ||
|
Member
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. why the call with underline? |
||
| expect = ['Check that a new sentence is created after a full stop, ! or ?.'] | ||
|
Member
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 expected value is wrong. it should repot a tuple of line number and error message |
||
| 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.""" | ||
| 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. \n' | ||
| 'New sentence.' | ||
| 'Sentence. 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) | ||
| 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(self): | ||
| """When a question mark is not the last character of the line, it is | ||
|
|
@@ -381,47 +380,23 @@ def test_semantic_newline_questionmark(self): | |
| 'Sentence? New sentence\n' | ||
| ) | ||
| checker = ReStructuredTextChecker('bogus', content, self.reporter) | ||
| checker.check_semantic_newline() | ||
| 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() | ||
| 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): | ||
| """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.
I think that this should be 0.4.0 as is add a new feature... 0.3.X is for bugfixes