Skip to content

Commit

Permalink
Merge e432db1 into c1bd2fe
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhs committed Feb 7, 2020
2 parents c1bd2fe + e432db1 commit 30752ba
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 87 deletions.
15 changes: 8 additions & 7 deletions docs/mythx_cli.formatter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ mythx_cli.formatter.tabular
:undoc-members:
:show-inheritance:

mythx_cli.formatter.sonarqube
-----------------------------

.. automodule:: mythx_cli.formatter.sonarqube
:members:
:undoc-members:
:show-inheritance:
..
mythx_cli.formatter.sonarqube
-----------------------------
.. automodule:: mythx_cli.formatter.sonarqube
:members:
:undoc-members:
:show-inheritance:


mythx_cli.formatter.util
Expand Down
4 changes: 3 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ JSON format to stdout. Currently the following formatters are available:
stdout.
* :code:`json-pretty`: The same as :code:`json`, just pretty-printed, with an
indentation of two spaces and alphabetically sorted object keys.
* :code:`sonar`: Print the results as JSON objects that can be interpreted by SonarQube.

..
* :code:`sonar`: Print the results as JSON objects that can be interpreted by SonarQube.

API Version Information
Expand Down
4 changes: 2 additions & 2 deletions mythx_cli/formatter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"json": JSONFormatter(),
"json-pretty": PrettyJSONFormatter(),
"table": TabularFormatter(),
"sonar": SonarQubeFormatter(),
# "sonar": SonarQubeFormatter(),
}

__all__ = [
JSONFormatter,
PrettyJSONFormatter,
SimpleFormatter,
TabularFormatter,
SonarQubeFormatter,
# SonarQubeFormatter,
]
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ coverage==5.0.3
tox==3.14.3

sphinx==2.3.1
sphinx_rtd_theme==0.4.3
watchdog==0.10.1
twine==3.1.1

Expand Down
154 changes: 77 additions & 77 deletions tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
ISSUES_SIMPLE = get_test_case("testdata/detected-issues-simple.txt", raw=True)
ISSUES_TABLE = get_test_case("testdata/detected-issues-table.txt", raw=True)
ISSUES_SONAR = get_test_case("testdata/detected-issues-sonar.json")
# ISSUES_SONAR = get_test_case("testdata/detected-issues-sonar.json")


def test_report_tabular():
Expand Down Expand Up @@ -95,82 +95,82 @@ def test_report_tabular_filter():
assert result.exit_code == 0


def test_report_sonar():
runner = CliRunner()
with mock_context():
result = runner.invoke(
cli,
[
"--format",
"sonar",
"analysis",
"report",
"ab9092f7-54d0-480f-9b63-1bb1508280e2",
],
)

assert json.loads(result.output) == ISSUES_SONAR
assert result.exit_code == 0


def test_report_sonar_blacklist():
runner = CliRunner()
with mock_context():
result = runner.invoke(
cli,
[
"--format",
"sonar",
"analysis",
"report",
"--swc-blacklist",
"SWC-110",
"ab9092f7-54d0-480f-9b63-1bb1508280e2",
],
)

assert all(x["forRule"] != "SWC-110" for x in json.loads(result.output))
assert result.exit_code == 0


def test_report_sonar_whitelist():
runner = CliRunner()
with mock_context():
result = runner.invoke(
cli,
[
"--format",
"sonar",
"analysis",
"report",
"--swc-whitelist",
"SWC-110",
"ab9092f7-54d0-480f-9b63-1bb1508280e2",
],
)

assert all(x["forRule"] == "SWC-110" for x in json.loads(result.output))
assert result.exit_code == 0


def test_report_sonar_filter():
runner = CliRunner()
with mock_context():
result = runner.invoke(
cli,
[
"--format",
"sonar",
"analysis",
"report",
"--min-severity",
"high",
"ab9092f7-54d0-480f-9b63-1bb1508280e2",
],
)

assert all(x["forRule"] != "SWC-110" for x in json.loads(result.output))
assert result.exit_code == 0
# def test_report_sonar():
# runner = CliRunner()
# with mock_context():
# result = runner.invoke(
# cli,
# [
# "--format",
# "sonar",
# "analysis",
# "report",
# "ab9092f7-54d0-480f-9b63-1bb1508280e2",
# ],
# )
#
# assert json.loads(result.output) == ISSUES_SONAR
# assert result.exit_code == 0
#
#
# def test_report_sonar_blacklist():
# runner = CliRunner()
# with mock_context():
# result = runner.invoke(
# cli,
# [
# "--format",
# "sonar",
# "analysis",
# "report",
# "--swc-blacklist",
# "SWC-110",
# "ab9092f7-54d0-480f-9b63-1bb1508280e2",
# ],
# )
#
# assert all(x["forRule"] != "SWC-110" for x in json.loads(result.output))
# assert result.exit_code == 0
#
#
# def test_report_sonar_whitelist():
# runner = CliRunner()
# with mock_context():
# result = runner.invoke(
# cli,
# [
# "--format",
# "sonar",
# "analysis",
# "report",
# "--swc-whitelist",
# "SWC-110",
# "ab9092f7-54d0-480f-9b63-1bb1508280e2",
# ],
# )
#
# assert all(x["forRule"] == "SWC-110" for x in json.loads(result.output))
# assert result.exit_code == 0
#
#
# def test_report_sonar_filter():
# runner = CliRunner()
# with mock_context():
# result = runner.invoke(
# cli,
# [
# "--format",
# "sonar",
# "analysis",
# "report",
# "--min-severity",
# "high",
# "ab9092f7-54d0-480f-9b63-1bb1508280e2",
# ],
# )
#
# assert all(x["forRule"] != "SWC-110" for x in json.loads(result.output))
# assert result.exit_code == 0


def test_report_json():
Expand Down

0 comments on commit 30752ba

Please sign in to comment.