pedroMMM/goss

View on GitHub

Showing 439 of 439 total issues

Function matcherToGomegaMatcher has 18 return statements (exceeds 4 allowed).
Open

func matcherToGomegaMatcher(matcher interface{}) (types.GomegaMatcher, error) {
    switch x := matcher.(type) {
    case string, int, bool, float64:
        return gomega.Equal(x), nil
    case []interface{}:
Severity: Major
Found in resource/gomega.go - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s *ServiceSystemd) Enabled() (bool, error) {
        if invalidService(s.service) {
            return false, nil
        }
        cmd := util.NewCommand("systemctl", "-q", "is-enabled", s.service)
    Severity: Major
    Found in system/service_systemd.go and 1 other location - About 1 hr to fix
    system/service_systemd.go on lines 70..87

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 162.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s *ServiceSystemd) Running() (bool, error) {
        if invalidService(s.service) {
            return false, nil
        }
        cmd := util.NewCommand("systemctl", "-q", "is-active", s.service)
    Severity: Major
    Found in system/service_systemd.go and 1 other location - About 1 hr to fix
    system/service_systemd.go on lines 51..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 162.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function AddResource has 16 return statements (exceeds 4 allowed).
    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)
    Severity: Major
    Found in add.go - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (f *DefFile) Md5() (string, error) {
      
          if err := f.setup(); err != nil {
              return "", err
          }
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 242..260

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 158.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (f *DefFile) Sha256() (string, error) {
      
          if err := f.setup(); err != nil {
              return "", err
          }
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 222..240

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 158.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (f *DefFile) Owner() (string, error) {
          if err := f.setup(); err != nil {
              return "", err
          }
      
      
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 167..183

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 155.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (f *DefFile) Group() (string, error) {
          if err := f.setup(); err != nil {
              return "", err
          }
      
      
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 149..165

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 155.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func getUserForUid(uid int) (string, error) {
          if user, err := user.LookupUid(uid); err == nil {
              return user.Name, nil
          }
      
      
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 276..288

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 148.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func getGroupForGid(gid int) (string, error) {
          if group, err := user.LookupGid(gid); err == nil {
              return group.Name, nil
          }
      
      
      Severity: Major
      Found in system/file.go and 1 other location - About 1 hr to fix
      system/file.go on lines 262..274

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 148.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function ValidateContains has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
      Open

      func ValidateContains(res ResourceRead, property string, expectedValues []string, method func() (io.Reader, error), skip bool) TestResult {
          id := res.ID()
          title := res.GetTitle()
          meta := res.GetMeta()
          typ := reflect.TypeOf(res)
      Severity: Minor
      Found in resource/validate.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 getGossConfig has 9 return statements (exceeds 4 allowed).
      Open

      func getGossConfig(vars string, varsInline string, specFile string) (cfg *GossConfig, err error) {
          // handle stdin
          var fh *os.File
          var path, source string
          var gossConfig GossConfig
      Severity: Major
      Found in validate.go - About 55 mins to fix

        Function skipResult has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func skipResult(typeS string, testType int, id string, title string, meta meta, property string, startTime time.Time) TestResult {
        Severity: Major
        Found in resource/validate.go - About 50 mins to fix

          Method MatchingMap.UnmarshalJSON has 7 return statements (exceeds 4 allowed).
          Open

          func (ret *MatchingMap) UnmarshalJSON(data []byte) error {
              // Curried json.Unmarshal
              unmarshal := func(i interface{}) error {
                  if err := json.Unmarshal(data, i); err != nil {
                      return err
          Severity: Major
          Found in resource/matching.go - About 45 mins to fix

            Method ResourceTypeMap.UnmarshalJSON has 7 return statements (exceeds 4 allowed).
            Open

            func (ret *ResourceTypeMap) UnmarshalJSON(data []byte) error {
                // Curried json.Unmarshal
                unmarshal := func(i interface{}) error {
                    if err := json.Unmarshal(data, i); err != nil {
                        return err
            Severity: Major
            Found in resource/resource_list_genny.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                  } else if _, err := os.Stat("/etc/debian_version"); err == nil {
                      return "debian"
                  }
              Severity: Major
              Found in system/system.go - About 45 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                {
                                    Name:  "addr",
                                    Usage: "add new remote address:port - ex: google.com:80",
                                    Flags: []cli.Flag{
                                        cli.DurationFlag{
                Severity: Minor
                Found in cmd/goss/goss.go and 1 other location - About 45 mins to fix
                cmd/goss/goss.go on lines 281..293

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 114.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                {
                                    Name:  "command",
                                    Usage: "add new command",
                                    Flags: []cli.Flag{
                                        cli.DurationFlag{
                Severity: Minor
                Found in cmd/goss/goss.go and 1 other location - About 45 mins to fix
                cmd/goss/goss.go on lines 240..252

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 114.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function DetectDistro has 6 return statements (exceeds 4 allowed).
                Open

                func DetectDistro() string {
                    if b, e := ioutil.ReadFile("/etc/lsb-release"); e == nil && bytes.Contains(b, []byte("Ubuntu")) {
                        return "ubuntu"
                    } else if isRedhat() {
                        return "redhat"
                Severity: Major
                Found in system/system.go - About 40 mins to fix

                  Function mergeJSONData has 6 return statements (exceeds 4 allowed).
                  Open

                  func mergeJSONData(gossConfig GossConfig, depth int, path string) (GossConfig, error) {
                      depth++
                      if depth >= 50 {
                          return GossConfig{}, fmt.Errorf("max depth of 50 reached, possibly due to dependency loop in goss file")
                      }
                  Severity: Major
                  Found in store.go - About 40 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language