pedroMMM/goss

View on GitHub

Showing 439 of 439 total issues

Function main has 321 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    startTime := time.Now()
    app := cli.NewApp()
    app.EnableBashCompletion = true
    app.Version = version
Severity: Major
Found in cmd/goss/goss.go - About 1 day to fix

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

    package resource
    
    import (
        "github.com/aelsabbahy/goss/system"
        "github.com/aelsabbahy/goss/util"
    Severity: Major
    Found in resource/port.go and 1 other location - About 7 hrs to fix
    resource/package.go on lines 1..55

    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 511.

    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

    package resource
    
    import (
        "github.com/aelsabbahy/goss/system"
        "github.com/aelsabbahy/goss/util"
    Severity: Major
    Found in resource/package.go and 1 other location - About 7 hrs to fix
    resource/port.go on lines 1..55

    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 511.

    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 125 lines of code (exceeds 50 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: Major
    Found in resource/validate.go - About 4 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      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 and 1 other location - About 3 hrs to fix
      resource/matching.go on lines 43..78

      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 290.

      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 (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 and 1 other location - About 3 hrs to fix
      resource/resource_list_genny.go on lines 53..88

      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 290.

      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 matcherToGomegaMatcher has 101 lines of code (exceeds 50 allowed). Consider refactoring.
      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 3 hrs to fix

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

        func (ret *MatchingMap) UnmarshalYAML(unmarshal func(v interface{}) error) error {
            // Validate configuration
            zero := Matching{}
            whitelist, err := util.WhitelistAttrs(zero, util.YAML)
            if err != nil {
        Severity: Major
        Found in resource/matching.go and 1 other location - About 2 hrs to fix
        resource/resource_list_genny.go on lines 90..117

        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 247.

        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 (ret *ResourceTypeMap) UnmarshalYAML(unmarshal func(v interface{}) error) error {
            // Validate configuration
            zero := ResourceType{}
            whitelist, err := util.WhitelistAttrs(zero, util.YAML)
            if err != nil {
        Severity: Major
        Found in resource/resource_list_genny.go and 1 other location - About 2 hrs to fix
        resource/matching.go on lines 80..107

        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 247.

        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 95 lines of code (exceeds 50 allowed). Consider refactoring.
        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 2 hrs to fix

          Function matcherToGomegaMatcher has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
          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: Minor
          Found in resource/gomega.go - About 2 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 ValidateValue has 79 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func ValidateValue(res ResourceRead, property string, expectedValue interface{}, actual interface{}, skip bool) TestResult {
              id := res.ID()
              title := res.GetTitle()
              meta := res.GetMeta()
              typ := reflect.TypeOf(res)
          Severity: Major
          Found in resource/validate.go - About 2 hrs to fix

            Function AddResource has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
            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: Minor
            Found in add.go - About 2 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 AutoAddResource has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
            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)
            Severity: Minor
            Found in add.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 main has 20 return statements (exceeds 4 allowed).
            Open

            func main() {
                startTime := time.Now()
                app := cli.NewApp()
                app.EnableBashCompletion = true
                app.Version = version
            Severity: Major
            Found in cmd/goss/goss.go - About 1 hr to fix

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

              func LookupA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
                  m.SetQuestion(dns.Fqdn(host), dns.TypeA)
                  r, _, err := c.Exchange(m, parseServerString(server))
                  if err != nil {
                      return nil, err
              Severity: Major
              Found in system/dns.go and 1 other location - About 1 hr to fix
              system/dns.go on lines 202..216

              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 178.

              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 LookupAAAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
                  m.SetQuestion(dns.Fqdn(host), dns.TypeAAAA)
                  r, _, err := c.Exchange(m, parseServerString(server))
                  if err != nil {
                      return nil, err
              Severity: Major
              Found in system/dns.go and 1 other location - About 1 hr to fix
              system/dns.go on lines 175..189

              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 178.

              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 3 locations. Consider refactoring.
              Open

              func LookupTXT(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
                  m.SetQuestion(dns.Fqdn(host), dns.TypeTXT)
                  r, _, err := c.Exchange(m, parseServerString(server))
                  if err != nil {
                      return nil, err
              Severity: Major
              Found in system/dns.go and 2 other locations - About 1 hr to fix
              system/dns.go on lines 219..233
              system/dns.go on lines 254..268

              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 172.

              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 3 locations. Consider refactoring.
              Open

              func LookupCNAME(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
                  m.SetQuestion(dns.Fqdn(host), dns.TypeCNAME)
                  r, _, err := c.Exchange(m, parseServerString(server))
                  if err != nil {
                      return nil, err
              Severity: Major
              Found in system/dns.go and 2 other locations - About 1 hr to fix
              system/dns.go on lines 254..268
              system/dns.go on lines 292..306

              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 172.

              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 3 locations. Consider refactoring.
              Open

              func LookupNS(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
                  m.SetQuestion(dns.Fqdn(host), dns.TypeNS)
                  r, _, err := c.Exchange(m, parseServerString(server))
                  if err != nil {
                      return nil, err
              Severity: Major
              Found in system/dns.go and 2 other locations - About 1 hr to fix
              system/dns.go on lines 219..233
              system/dns.go on lines 292..306

              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 172.

              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

              Severity
              Category
              Status
              Source
              Language