This section covers .deepsource.toml
configuration specific to the go
analyzer. Please make sure to read the general configuration guide first.
name
enabled
meta
import_paths
import_root
skip_doc_coverage
file
file
- Do not include file docs while calculating documentation coverage.dependencies_vendored
true
, false
false
build_tags
cgo_enabled
import_path
import_path
is now deprecated. It will still be used if the import_paths
array is empty, for backward compatibility. It is recommended to configure import_root
and let the analyzer automatically figure out the import_paths
instead of using this field.
cyclomatic_complexity_threshold
low
will flag all functions that have a cyclomatic complexity of more than 5
, while setting the threshold to critical
will not flag any function.low
, medium
, high
, very-high
and critical
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. |
medium
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.
The analyzer supports coverage profile (report) for all three modes — set
, atomic
, and count
generated by the go test
.
This is how you can generate a coverage profile and report it to the analyzer:
Note: Tests for different Go packages
If you are running tests and generating coverage reports for different packages separately, you need to combine all generated coverage reports into a single file and submit that to the test-coverage
analyzer.
This is how you can combine the coverage artifacts before reporting them:
gofmt
Transform all incoming Go code with gofmt, the official Go code formatter.
This section covers .deepsource.toml
configuration specific to the gofmt
transformer. Please make sure to read the general configuration guide first.
gofumpt
Transform all incoming Go code with gofumpt, an opinionated formatter based on gofmt that enforces a stricter format and adds additional rules to make Go code more consistent.
This section covers .deepsource.toml
configuration specific to the gofumpt
transformer. Please make sure to read the general configuration guide first.
Supported target files:
go.mod
go.sum
This section covers .deepsource.toml
configuration specific to the go
analyzer. Please make sure to read the general configuration guide first.
name
enabled
meta
import_paths
import_root
skip_doc_coverage
file
file
- Do not include file docs while calculating documentation coverage.dependencies_vendored
true
, false
false
build_tags
cgo_enabled
import_path
import_path
is now deprecated. It will still be used if the import_paths
array is empty, for backward compatibility. It is recommended to configure import_root
and let the analyzer automatically figure out the import_paths
instead of using this field.
cyclomatic_complexity_threshold
low
will flag all functions that have a cyclomatic complexity of more than 5
, while setting the threshold to critical
will not flag any function.low
, medium
, high
, very-high
and critical
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. |
medium
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.
The analyzer supports coverage profile (report) for all three modes — set
, atomic
, and count
generated by the go test
.
This is how you can generate a coverage profile and report it to the analyzer:
Note: Tests for different Go packages
If you are running tests and generating coverage reports for different packages separately, you need to combine all generated coverage reports into a single file and submit that to the test-coverage
analyzer.
This is how you can combine the coverage artifacts before reporting them:
gofmt
Transform all incoming Go code with gofmt, the official Go code formatter.
This section covers .deepsource.toml
configuration specific to the gofmt
transformer. Please make sure to read the general configuration guide first.
gofumpt
Transform all incoming Go code with gofumpt, an opinionated formatter based on gofmt that enforces a stricter format and adds additional rules to make Go code more consistent.
This section covers .deepsource.toml
configuration specific to the gofumpt
transformer. Please make sure to read the general configuration guide first.
Supported target files:
go.mod
go.sum