|
1 | 1 | from coalib.bearlib.languages.documentation.DocumentationComment import (
|
2 |
| - DocumentationComment) |
| 2 | + DocumentationComment, MalformedComment) |
3 | 3 | from coalib.bearlib.languages.documentation.DocstyleDefinition import (
|
4 | 4 | DocstyleDefinition)
|
5 | 5 | from coalib.bearlib.languages.documentation.DocBaseClass import (
|
@@ -124,22 +124,29 @@ def run(self, filename, file, language: str,
|
124 | 124 | """
|
125 | 125 |
|
126 | 126 | for doc_comment in self.extract(file, language, docstyle):
|
127 |
| - parsed = doc_comment.parse() |
128 |
| - |
129 |
| - (new_metadata, warning_desc) = self.process_documentation( |
130 |
| - parsed, allow_missing_func_desc, indent_size, |
131 |
| - expand_one_liners) |
132 |
| - |
133 |
| - new_comment = DocumentationComment.from_metadata( |
134 |
| - new_metadata, doc_comment.docstyle_definition, |
135 |
| - doc_comment.marker, doc_comment.indent, doc_comment.position) |
136 |
| - |
137 |
| - if new_comment != doc_comment: |
138 |
| - # Something changed, let's apply a result. |
139 |
| - diff = self.generate_diff(file, doc_comment, new_comment) |
140 |
| - |
141 |
| - yield Result( |
| 127 | + if isinstance(doc_comment, MalformedComment): |
| 128 | + yield Result.from_values( |
142 | 129 | origin=self,
|
143 |
| - message=warning_desc, |
144 |
| - affected_code=(diff.range(filename),), |
145 |
| - diffs={filename: diff}) |
| 130 | + message=doc_comment.message, |
| 131 | + file=filename, |
| 132 | + line=doc_comment.line + 1) |
| 133 | + else: |
| 134 | + parsed = doc_comment.parse() |
| 135 | + |
| 136 | + (new_metadata, warning_desc) = self.process_documentation( |
| 137 | + parsed, allow_missing_func_desc, indent_size, |
| 138 | + expand_one_liners) |
| 139 | + |
| 140 | + new_comment = DocumentationComment.from_metadata( |
| 141 | + new_metadata, doc_comment.docstyle_definition, |
| 142 | + doc_comment.marker, doc_comment.indent, |
| 143 | + doc_comment.position) |
| 144 | + |
| 145 | + if new_comment != doc_comment: |
| 146 | + # Something changed, let's apply a result. |
| 147 | + diff = self.generate_diff(file, doc_comment, new_comment) |
| 148 | + yield Result( |
| 149 | + origin=self, |
| 150 | + message=warning_desc, |
| 151 | + affected_code=(diff.range(filename),), |
| 152 | + diffs={filename: diff}) |
0 commit comments