Showing 20 of 20 total issues
Function runServiceBuild
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func runServiceBuild(srvs map[string]*DepService, stateCom *statecom.StateCom, testAll, shouldDeploy *bool) error {
doneChan := make(chan string)
errChan := make(chan error)
buildTotal := 0
for i := range srvs {
- 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 checkStructs
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
func checkStructs(test, expected interface{}) error {
expectedMap := structs.Map(expected)
testMap := structs.Map(test)
for key := range expectedMap {
val := testMap[key]
- 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 TestLoad
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestLoad(t *testing.T) {
expected := &Config{
Environment: Environment{
Exec: []string{"docker pull cpg1111/maestro"},
},
Function build
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func build(srv *DepService, index string, stateCom *statecom.StateCom, done chan string, errChan chan error, shouldDeploy *bool) {
Method Service.ShouldBuild
has 7 return statements (exceeds 4 allowed). Open
func (s *Service) ShouldBuild(repo *git.Repository, lastBuildCommit, currBuildCommit *string) (bool, error) {
if s.shouldBuild {
return s.shouldBuild, nil
}
prevTree, err := util.CommitToTree(repo, *lastBuildCommit)
Avoid deeply nested control flow statements. Open
} else if count == len(conf.Exec)*2 {
close(status)
return nil
}
Avoid deeply nested control flow statements. Open
if runErr != nil {
return runErr
}
Avoid deeply nested control flow statements. Open
if total < buildTotal {
siblingFailed = true
continue
}
Method Service.execSrvCmd
has 7 return statements (exceeds 4 allowed). Open
func (s *Service) execSrvCmd(cmdStr, path string) (*exec.Cmd, error) {
if cmdStr == "" {
return nil, errors.New("empty string is not a valid command")
}
cmdStr, err := util.TemplateCommits(cmdStr, s.lastCommit, s.currCommit)
Function checkStructs
has 6 return statements (exceeds 4 allowed). Open
func checkStructs(test, expected interface{}) error {
expectedMap := structs.Map(expected)
testMap := structs.Map(test)
for key := range expectedMap {
val := testMap[key]
Function Run
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func Run(depTree *DepTree, repo *git.Repository, stateCom *statecom.StateCom, lastBuildCommit, currBuildCommit *string, testAll, shouldDeploy *bool) error {
Function Load
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func Load(conf *config.Environment) error {
if len(conf.Env) > 0 {
for h := range conf.Env {
kv := strings.Split(conf.Env[h], ":")
key := strings.ToUpper(kv[0])
- 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 healthcheckHTTPGet
has 5 return statements (exceeds 4 allowed). Open
func healthcheckHTTPGet(endpoint, response string) error {
resp, err := http.Get(endpoint)
if err != nil {
return err
}
Function build
has 5 return statements (exceeds 4 allowed). Open
func build(srv *DepService, index string, stateCom *statecom.StateCom, done chan string, errChan chan error, shouldDeploy *bool) {
buildName := srv.build.conf.Name
stateCom.Services[buildName].SetState("building", true)
err := srv.build.execBuild()
if err != nil {
Function runServiceBuild
has 5 return statements (exceeds 4 allowed). Open
func runServiceBuild(srvs map[string]*DepService, stateCom *statecom.StateCom, testAll, shouldDeploy *bool) error {
doneChan := make(chan string)
errChan := make(chan error)
buildTotal := 0
for i := range srvs {
don't use MixedCaps in package name; cleanUp should be cleanup Open
package cleanUp
- Exclude checks
2: cannot find package "github.com/cpg1111/maestro/config" in any of: Open
"github.com/cpg1111/maestro/config"
- Exclude checks
don't use MixedCaps in package name; cleanUp should be cleanup Open
package cleanUp
- Exclude checks
exported const PTAttach should have comment or be unexported Open
const PTAttach = "PTRACE_ATTACH"
- Exclude checks
TODO found Open
// TODO send status to daemon
- Exclude checks