add.go
Function AddResource
has 95 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
Function AddResource
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function AutoAddResource
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
Open
func AutoAddResource(fileName string, gossConfig GossConfig, key string, sys *system.System) error {
// file
if strings.Contains(key, "/") {
if res, _, ok := gossConfig.Files.AppendSysResourceIfExists(key, sys); ok == true {
resourcePrint(fileName, res)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function AddResource
has 16 return statements (exceeds 4 allowed). Open
Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
// Need to figure out a good way to refactor this
switch resourceName {
case "Addr":
res, err := gossConfig.Addrs.AppendSysResource(key, sys, config)
Function AddResource
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
2: cannot find package "github.com/aelsabbahy/goss/system" in any of: Open
Open
"github.com/aelsabbahy/goss/system"
- Exclude checks
comment on exported function AutoAddResources should be of the form "AutoAddResources ..." Open
Open
// Simple wrapper to add multiple resources
- Exclude checks
exported function AddResource should have comment or be unexported Open
Open
func AddResource(fileName string, gossConfig GossConfig, resourceName, key string, config util.Config, sys *system.System) error {
- Exclude checks
comment on exported function AddResources should be of the form "AddResources ..." Open
Open
// Simple wrapper to add multiple resources
- Exclude checks
exported function AutoAddResource should have comment or be unexported Open
Open
func AutoAddResource(fileName string, gossConfig GossConfig, key string, sys *system.System) error {
- Exclude checks