Java
Configuration - .deepsource.toml
.deepsource.toml
This section covers configuration details specific to the Java analyzer. Please ensure that you have read the general configuration guide first.
The Java analyzer supports Gradle, Maven and Bazel projects. There is no difference in configuration between them, and all types of projects can be initialized through the simple workflow of the DeepSource configuration generator.
name
name
- Type: String
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
name = "java"
enabled
enabled
- Type: Boolean
- Presence: optional
- Description: Toggle whether this analyzer should be run.
- Example:
enabled = true
meta
meta
- Type: Table
- Presence: mandatory
- Description: Additional data used to configure the analyzer.
- Example:
[analyzers.meta]
runtime_version = "8"
runtime_version
runtime_version
- Type: String
- Presence: mandatory
- Description: The Java runtime version to use when running the analyzer. OpenJDK versions 8 to 21 are currently supported.
- Aliases:
java_version
- Example:
[analyzers.meta]
runtime_version = "13"
if
runtime_version
is not specified, or is the wrong Java version, analysis may show incorrect results. Specify the Java version you use in CI for best results.
skip_doc_coverage
skip_doc_coverage
-
Type: Array
-
Presence: optional
-
Description: Specify which artifacts to skip when calculating documentation coverage.
-
Available Values:
test
,class
,constructor
andnonpublic
test
- Ignore documentation coverage within testsclass
- Ignore class documentation coverageconstructor
- Ignore constructor documentation coveragenonpublic
- Ignore documentation coverage for any declaration not marked aspublic
-
Default Value:
[ "test" ]
-
Example:
skip_doc_coverage = [ "nonpublic", "test" ]
If
skip_doc_coverage
is set, it will override any default configuration. That is, if this key is set, and you wish to ensure documentation coverage is skipped for elements that are skipped by default (like tests), you must specify those as well as the additional elements you wish to skip.
cyclomatic_complexity_threshold
cyclomatic_complexity_threshold
-
Type: String
-
Presence: optional
-
Description: Specify the acceptable risk category for your project as the threshold. All functions with complexity beyond this threshold will raise an issue. For example, setting the threshold to
low
will flag all functions that have a cyclomatic complexity of more than5
, while setting the threshold tocritical
will not flag any function. -
Available Values:
low
,medium
,high
,very-high
andcritical
Risk category | Cyclomatic complexity range | Recommended action |
---|---|---|
low | 1-5 | No action is needed. |
medium | 6-15 | Review and monitor. |
high | 16-25 | Review and refactor. Recommended to add detailed comments if the function absolutely needs to be kept as it is. |
very-high | 26-50 | Refactor to reduce the complexity. |
critical | > 50 | Must refactor this. This can make the code untestable and very difficult to understand. |
- Default Value:
medium
- Example:
[analyzers.meta]
cyclomatic_complexity_threshold = "high"
Sample config
version = 1
[[analyzers]]
name = "java"
enabled = true
[analyzers.meta]
runtime_version = "8"
Updated 7 months ago