Skip to content

Commit

Permalink
fix: create directories of json report (refs #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Feb 26, 2023
1 parent a9c018b commit 82a6411
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| --- | --- | ---
| [_ARM-GCC_](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm) | `CLANG` |
| [_AndroidLint_](http://developer.android.com/tools/help/lint.html) | `ANDROIDLINT` |
| [_Ansible-Later_](https://github.com/thegeeklab/ansible-later) | `ANSIBLELATER` | With `json` format
| [_AnsibleLint_](https://github.com/willthames/ansible-lint) | `FLAKE8` | With `-p`
| [_Bandit_](https://github.com/PyCQA/bandit) | `CLANG` | With `bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}"`
| [_CLang_](https://clang-analyzer.llvm.org/) | `CLANG` |
Expand Down Expand Up @@ -129,6 +130,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_SARIF_](https://github.com/oasis-tcs/sarif-spec) | `SARIF` | v2.x. Microsoft Visual C# can generate it with `ErrorLog="BuildErrors.sarif,version=2"`.
| [_SbtScalac_](http://www.scala-sbt.org/) | `SBTSCALAC` |
| [_Scalastyle_](http://www.scalastyle.org/) | `CHECKSTYLE` |
| [_Semgrep_](https://semgrep.dev/) | `SEMGREP` | With `--json`.
| [_Simian_](http://www.harukizaemon.com/simian/) | `SIMIAN` |
| [_Sonar_](https://www.sonarqube.org/) | `SONAR` | With `mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json`. Removed in 7.7, see [SONAR-11670](https://jira.sonarsource.com/browse/SONAR-11670) but can be retrieved with: `curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' \| jq -f sonar-report-builder.jq > sonar-report.json`.
| [_Spotbugs_](https://spotbugs.github.io/) | `FINDBUGS` |
Expand All @@ -141,7 +143,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_YAMLLint_](https://yamllint.readthedocs.io/en/stable/index.html) | `YAMLLINT` | With `-f parsable`
| [_ZPTLint_](https://pypi.python.org/pypi/zptlint) | `ZPTLINT` |

49 parsers and 75 reporters.
51 parsers and 77 reporters.

Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations-lib/issues)!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -110,12 +111,10 @@ public void log(final Level level, final String string, final Throwable t) {

private void createJsonFile(final Object object, final File file) throws IOException {
final String codeClimateReport = new GsonBuilder().setPrettyPrinting().create().toJson(object);
final Path path = file.toPath();
path.toFile().getParentFile().mkdirs();
Files.write(
file.toPath(),
codeClimateReport.getBytes(StandardCharsets.UTF_8),
TRUNCATE_EXISTING,
CREATE,
WRITE);
path, codeClimateReport.getBytes(StandardCharsets.UTF_8), TRUNCATE_EXISTING, CREATE, WRITE);
}

private void checkGlobalViolations(final Set<Violation> violations) throws ScriptException {
Expand Down

0 comments on commit 82a6411

Please sign in to comment.