-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6063d15
commit acfe331
Showing
9 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/se/bjurr/violations/lib/parsers/MyPyParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package se.bjurr.violations.lib.parsers; | ||
|
||
import static java.lang.Integer.parseInt; | ||
import static se.bjurr.violations.lib.model.SEVERITY.ERROR; | ||
import static se.bjurr.violations.lib.model.SEVERITY.INFO; | ||
import static se.bjurr.violations.lib.model.Violation.violationBuilder; | ||
import static se.bjurr.violations.lib.parsers.ViolationParserUtils.getLines; | ||
import static se.bjurr.violations.lib.reports.Reporter.MYPY; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import se.bjurr.violations.lib.model.SEVERITY; | ||
import se.bjurr.violations.lib.model.Violation; | ||
|
||
public class MyPyParser implements ViolationsParser { | ||
|
||
@Override | ||
public List<Violation> parseReportOutput(String reportContent) throws Exception { | ||
List<Violation> violations = new ArrayList<>(); | ||
List<List<String>> partsPerLine = getLines(reportContent, "^(.*):(\\d+): (.*): (.*)$"); | ||
for (List<String> parts : partsPerLine) { | ||
String fileName = parts.get(1); | ||
Integer lineNumber = 0; | ||
if (!parts.get(2).isEmpty()) { | ||
lineNumber = parseInt(parts.get(2)); | ||
} | ||
String severity = parts.get(3); | ||
String message = parts.get(4); | ||
violations.add(// | ||
violationBuilder()// | ||
.setReporter(MYPY)// | ||
.setStartLine(lineNumber)// | ||
.setFile(fileName)// | ||
.setSeverity(toSeverity(severity))// | ||
.setMessage(message)// | ||
.build()// | ||
); | ||
} | ||
return violations; | ||
} | ||
|
||
public SEVERITY toSeverity(String severity) { | ||
if (severity.equalsIgnoreCase("error")) { | ||
return ERROR; | ||
} | ||
return INFO; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/se/bjurr/violations/lib/parsers/PyDocStyleParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package se.bjurr.violations.lib.parsers; | ||
|
||
import static java.lang.Integer.parseInt; | ||
import static se.bjurr.violations.lib.model.SEVERITY.ERROR; | ||
import static se.bjurr.violations.lib.model.Violation.violationBuilder; | ||
import static se.bjurr.violations.lib.parsers.ViolationParserUtils.getParts; | ||
import static se.bjurr.violations.lib.reports.Reporter.PYDOCSTYLE; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import se.bjurr.violations.lib.model.Violation; | ||
|
||
public class PyDocStyleParser implements ViolationsParser { | ||
|
||
@Override | ||
public List<Violation> parseReportOutput(String string) throws Exception { | ||
List<Violation> violations = new ArrayList<>(); | ||
boolean fileLine = true; | ||
List<String> lines = ViolationParserUtils.getLines(string); | ||
String filename = null; | ||
Integer line = null; | ||
for (String inputLine : lines) { | ||
if (fileLine) { | ||
List<String> parts = getParts(inputLine, "([^:]*)", "(\\d+)"); | ||
filename = parts.get(0); | ||
line = parseInt(parts.get(1)); | ||
} else { | ||
List<String> parts = getParts(inputLine, "([^:]*)", ":(.*)"); | ||
String rule = parts.get(0); | ||
String message = parts.get(1); | ||
|
||
violations.add(// | ||
violationBuilder()// | ||
.setReporter(PYDOCSTYLE)// | ||
.setStartLine(line)// | ||
.setFile(filename)// | ||
.setRule(rule)// | ||
.setSeverity(ERROR)// | ||
.setMessage(message)// | ||
.build()// | ||
); | ||
} | ||
fileLine = !fileLine; | ||
} | ||
return violations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package se.bjurr.violations.lib; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static se.bjurr.violations.lib.TestUtils.getRootFolder; | ||
import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; | ||
import static se.bjurr.violations.lib.model.SEVERITY.ERROR; | ||
import static se.bjurr.violations.lib.model.Violation.violationBuilder; | ||
import static se.bjurr.violations.lib.reports.Reporter.MYPY; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import se.bjurr.violations.lib.model.Violation; | ||
|
||
/** | ||
* Created by matthew on 27/04/16. | ||
*/ | ||
public class MyPyTest { | ||
|
||
@Test | ||
public void testThatViolationsCanBeParsed() { | ||
|
||
String rootFolder = getRootFolder(); | ||
|
||
List<Violation> actual = violationsReporterApi() // | ||
.withPattern(".*/mypy/.*\\.txt$") // | ||
.inFolder(rootFolder)// | ||
.findAll(MYPY) // | ||
.violations(); | ||
|
||
assertThat(actual)// | ||
.hasSize(5); | ||
|
||
assertThat(actual.get(0))// | ||
.isEqualTo(// | ||
violationBuilder()// | ||
.setReporter(MYPY)// | ||
.setFile("fs/cs/backend/log.py") // | ||
.setStartLine(16)// | ||
.setMessage("\"LogRecord\" has no attribute \"user_uuid\"") // | ||
.setSeverity(ERROR) // | ||
.build() // | ||
); | ||
|
||
assertThat(actual.get(1))// | ||
.isEqualTo(// | ||
violationBuilder()// | ||
.setReporter(MYPY)// | ||
.setFile("fs/cs/backend/log.py") // | ||
.setStartLine(17)// | ||
.setMessage("\"LogRecord\" has no attribute \"tenant_id\"") // | ||
.setSeverity(ERROR) // | ||
.build() // | ||
); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package se.bjurr.violations.lib; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static se.bjurr.violations.lib.TestUtils.getRootFolder; | ||
import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; | ||
import static se.bjurr.violations.lib.model.SEVERITY.ERROR; | ||
import static se.bjurr.violations.lib.model.Violation.violationBuilder; | ||
import static se.bjurr.violations.lib.reports.Reporter.PYDOCSTYLE; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import se.bjurr.violations.lib.model.Violation; | ||
|
||
/** | ||
* Created by matthew on 27/04/16. | ||
*/ | ||
public class PyDocStyleTest { | ||
|
||
@Test | ||
public void testThatViolationsCanBeParsed() { | ||
|
||
String rootFolder = getRootFolder(); | ||
|
||
List<Violation> actual = violationsReporterApi() // | ||
.withPattern(".*/pydocstyle/.*\\.txt$") // | ||
.inFolder(rootFolder)// | ||
.findAll(PYDOCSTYLE) // | ||
.violations(); | ||
|
||
assertThat(actual)// | ||
.hasSize(33); | ||
|
||
assertThat(actual.get(0))// | ||
.isEqualTo(// | ||
violationBuilder()// | ||
.setReporter(PYDOCSTYLE)// | ||
.setFile("fs/csm/admin_api/ui_api.py") // | ||
.setStartLine(1) // | ||
.setRule("D100") // | ||
.setMessage("Missing docstring in public module") // | ||
.setSeverity(ERROR) // | ||
.build() // | ||
); | ||
|
||
assertThat(actual.get(1))// | ||
.isEqualTo(// | ||
violationBuilder()// | ||
.setReporter(PYDOCSTYLE)// | ||
.setFile("fs/csm/admin_api/main.py") // | ||
.setStartLine(1) // | ||
.setRule("D100") // | ||
.setMessage("Missing docstring in public module") // | ||
.setSeverity(ERROR) // | ||
.build() // | ||
); | ||
|
||
assertThat(actual.get(20))// | ||
.isEqualTo(// | ||
violationBuilder()// | ||
.setReporter(PYDOCSTYLE)// | ||
.setFile("fs/csm/admin_api/auth.py") // | ||
.setStartLine(73) // | ||
.setRule("D101") // | ||
.setMessage("Missing docstring in public class") // | ||
.setSeverity(ERROR) // | ||
.build() // | ||
); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fs/cs/backend/log.py: note: In member "filter" of class "CsLogFilter": | ||
fs/cs/backend/log.py:16: error: "LogRecord" has no attribute "user_uuid" | ||
fs/cs/backend/log.py:17: error: "LogRecord" has no attribute "tenant_id" | ||
fs/cs/backend/errorhandler.py: note: In member "__init__" of class "CsErrorHandler": | ||
fs/cs/backend/errorhandler.py:16: error: The return type of "__init__" must be None | ||
fs/cs/backend/api.py: note: At top level: | ||
fs/cs/backend/api.py:23: error: ContextManager[Any] not callable | ||
tests/test_schema.py:864: error: Name 'test_nested_only_and_exclude' already defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
fs/csm/admin_api/ui_api.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/main.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/dao.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/dao.py:8 in public class `Dao`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/admin_api.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/admin_api.py:34 in public function `x_debug_check`: | ||
D103: Missing docstring in public function | ||
fs/csm/admin_api/admin_api.py:40 in public class `NewNodeSchema`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/admin_api.py:227 in public class `NewChildNodeSchema`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/admin_api.py:463 in public class `NewParentNodeSchema`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/admin_api.py:614 in public class `PatchNodeSchema`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/settings.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/settings.py:12 in public class `SettingsService`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/settings.py:14 in public method `try_create_root_node`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/settings.py:26 in public method `try_create_child_node`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/settings.py:43 in public method `try_create_parent_node`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/sphinx.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/auth.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/auth.py:20 in public method `__init__`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/auth.py:25 in public method `__str__`: | ||
D105: Missing docstring in magic method | ||
fs/csm/admin_api/auth.py:38 in public method `authorize`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/auth.py:73 in public class `OAuth2Resolver`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/auth.py:126 in public class `AdminApiResolver`: | ||
D101: Missing docstring in public class | ||
fs/csm/admin_api/auth.py:128 in public method `__init__`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/auth.py:131 in public method `configure`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/auth.py:134 in public method `auth`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/auth.py:137 in public method `resolve`: | ||
D102: Missing docstring in public method | ||
fs/csm/admin_api/__init__.py:1 at module level: | ||
D104: Missing docstring in public package | ||
fs/csm/admin_api/application.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/application.py:46 in public function `build_app`: | ||
D103: Missing docstring in public function | ||
fs/csm/admin_api/wsgi.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/test/conftest.py:1 at module level: | ||
D100: Missing docstring in public module | ||
fs/csm/admin_api/test/conftest.py:18 in public function `admin_api_wsgi`: | ||
D103: Missing docstring in public function | ||
fs/csm/admin_api/test/__init__.py:1 at module level: | ||
D104: Missing docstring in public package |