Configuration — .deepsource.toml
.deepsource.toml
This section covers configuration specific to the go
Analyzer. Please make sure to read the general configuration guide first.
name
name
- Type: String
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
name = "go"
enabled
enabled
- Type: Boolean
- Presence: optional
- Description: Toggle whether this analyzer should be run.
- Example:
enabled = true
meta
meta
- Type: Table
- Presence: mandatory
- Description: Any supported metadata to pass to the analyzer.
- Example:
[analyzers.meta]
import_paths = ["github.com/deepsourcelabs/web-app/backend"]
import_paths
import_paths
- Type: Array
- Presence: optional
- Description: The Go analyzer by default automatically populates import_paths by searching for any available package managers. To override this behavior, all the import paths in the repository should be mentioned in this array.
- Default Value: None
- Example:
import_paths = ["github.com/deepsourcelabs/web-app/backend"]
import_root
import_root
- Type: String
- Presence: mandatory
- Description: Repository source code will be placed in $GOPATH/src/{import_root}. If you haven't yet migrated to Go Modules, you should configure import_root properly so that dependencies can be fetched for analysis.
- Default Value: None
- Example:
import_root = "github.com/deepsourcelabs/web-app"
skip_doc_coverage
skip_doc_coverage
- Type: Array
- Presence: optional
- Description: Specify which artifacts to skip when calculating documentation coverage.
- Available Value:
file
file
- Do not include file docs while calculating documentation coverage.
- Default Value: None
- Example:
skip_doc_coverage = ["file"]
dependencies_vendored
dependencies_vendored
- Type: Boolean
- Presence: optional
- Description: If set to true the analyzer doesn't install dependencies since they are already available in the vendor directory of the repository.
- Available Values:
true
,false
- Default Value:
false
- Example:
[analyzers.meta]
dependencies_vendored = true
build_tags
build_tags
- Type: Array
- Presence: optional
- Description: Specify the build tags with which the analyzer can determine whether a file should be included in the package. This prevents compilation-related issues due to the inclusion/exclusion of files based on tags (or constraints).
- Default Value: None
- Example:
build_tags = ["darwin"]
cgo_enabled
cgo_enabled
- Type: Boolean
- Presence: optional
- Description: Whether the analyzed packages will call C code using CGo. If the C code relies on external C libraries, they might not be present for analysis runs resulting in analysis failure. If your project does not use CGo, set the flag to false.
- Available Values: true, false
- Default Value: true
- Example:
cgo_enabled = false
import_path
import_path
- Type: String
- Presence: mandatory if import_paths is empty
- Description: The import path of the repository should be mentioned in this string.
- Default Value: None
- Example:
import_path = "github.com/deepsourcelabs/web-app/backend"
import_path
is now deprecated. It will still be used if theimport_paths
array is empty, for backward compatibility. It is recommended to configureimport_root
and let the analyzer automatically figure out theimport_paths
instead of using this field.
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
test_patterns = [
"tests/*_test.go",
"**/*_test.go"
]
[[analyzers]]
name = "go"
enabled = true
[analyzers.meta]
import_root = "github.com/deepsourcelabs/web-app"
dependencies_vendored = false
build_tags = ["darwin"]
cgo_enabled = false
Package managers
To conduct a thorough analysis of your code, DeepSource installs the dependencies required and examines them alongside your code. Our Go Analyzer identifies the package manager you've utilized, ensuring effortless integration. The package managers we currently support are:
File name | Package Manager |
---|---|
go.mod | go modules |
Gopkg.lock | dep |
GLOCKFILE | glock |
Godeps/Godeps.json | godep |
dependencies.tsv | godeps |
glide.lock | glide |
vendor.conf | trash |
trash.yaml | trash |
vendor/manifest | gvt |
vendor/vendor.json | govendor |
No dependency file | No deps installed |
If the meta property dependencies_vendored
is set to true
, dependency installation is skipped.
Updated 3 months ago