cpg1111/maestro

View on GitHub

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 {
Severity: Minor
Found in pipeline/build.go - About 3 hrs to fix

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]
Severity: Minor
Found in config/config_test.go - About 1 hr to fix

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"},
        },
Severity: Minor
Found in config/config_test.go - About 1 hr to fix

    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) {
    Severity: Minor
    Found in pipeline/build.go - About 45 mins to fix

      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)
      Severity: Major
      Found in pipeline/service.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        } else if count == len(conf.Exec)*2 {
                            close(status)
                            return nil
                        }
        Severity: Major
        Found in environment/env.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if runErr != nil {
                                  return runErr
                              }
          Severity: Major
          Found in pipeline/build.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if total < buildTotal {
                                    siblingFailed = true
                                    continue
                                }
            Severity: Major
            Found in pipeline/build.go - About 45 mins to fix

              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)
              Severity: Major
              Found in pipeline/service.go - About 45 mins to fix

                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]
                Severity: Major
                Found in config/config_test.go - About 40 mins to fix

                  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 {
                  Severity: Minor
                  Found in pipeline/build.go - About 35 mins to fix

                    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])
                    Severity: Minor
                    Found in environment/env.go - About 35 mins to fix

                    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
                        }
                    Severity: Major
                    Found in pipeline/healthcheck.go - About 35 mins to fix

                      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 {
                      Severity: Major
                      Found in pipeline/build.go - About 35 mins to fix

                        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 {
                        Severity: Major
                        Found in pipeline/build.go - About 35 mins to fix

                          don't use MixedCaps in package name; cleanUp should be cleanup
                          Open

                          package cleanUp
                          Severity: Minor
                          Found in cleanUp/cleanUp.go by golint

                          2: cannot find package "github.com/cpg1111/maestro/config" in any of:
                          Open

                              "github.com/cpg1111/maestro/config"
                          Severity: Minor
                          Found in cleanUp/cleanUp.go by govet

                          don't use MixedCaps in package name; cleanUp should be cleanup
                          Open

                          package cleanUp
                          Severity: Minor
                          Found in cleanUp/cleanUp_test.go by golint

                          exported const PTAttach should have comment or be unexported
                          Open

                          const PTAttach = "PTRACE_ATTACH"
                          Severity: Minor
                          Found in pipeline/healthcheck.go by golint

                          TODO found
                          Open

                                  // TODO send status to daemon
                          Severity: Minor
                          Found in cleanUp/cleanUp.go by fixme
                          Severity
                          Category
                          Status
                          Source
                          Language