thrawn01/args

View on GitHub

Showing 80 of 80 total issues

File parser_test.go has 678 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package args_test

import (
    "os"

Severity: Minor
Found in parser_test.go - About 6 hrs to fix

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

    var _ = Describe("ParserBenchMutex", func() {
        var server http.Handler
        var req *http.Request
        var resp *httptest.ResponseRecorder
        var api *Api
    Severity: Major
    Found in benchmark/benchmark_test.go and 2 other locations - About 5 hrs to fix
    benchmark/benchmark_test.go on lines 20..58
    benchmark/benchmark_test.go on lines 100..138

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

    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

    var _ = Describe("ParserBenchRWMutex", func() {
        var server http.Handler
        var req *http.Request
        var resp *httptest.ResponseRecorder
        var api *Api
    Severity: Major
    Found in benchmark/benchmark_test.go and 2 other locations - About 5 hrs to fix
    benchmark/benchmark_test.go on lines 20..58
    benchmark/benchmark_test.go on lines 60..98

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

    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

    var _ = Describe("ParserBench", func() {
        var server http.Handler
        var req *http.Request
        var resp *httptest.ResponseRecorder
        var api *Api
    Severity: Major
    Found in benchmark/benchmark_test.go and 2 other locations - About 5 hrs to fix
    benchmark/benchmark_test.go on lines 60..98
    benchmark/benchmark_test.go on lines 100..138

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

    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

    ArgParser has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type ArgParser struct {
        Command              *Rule
        EnvPrefix            string
        Description          string
        Name                 string
    Severity: Minor
    Found in parser.go - About 4 hrs to fix

      Options has 32 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type Options struct {
          log    StdLogger
          parser *ArgParser
          values map[string]Value
      }
      Severity: Minor
      Found in options.go - About 4 hrs to fix

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

                Context("Given multiple key=value pairs", func() {
                    It("Should return the next token found in the buffer", func() {
                        tokenizer := args.NewKeyValueTokenizer("key=value,key2=value2")
        
                        Expect(tokenizer.Next()).To(Equal("key"))
        Severity: Major
        Found in tokenizer_test.go and 1 other location - About 3 hrs to fix
        tokenizer_test.go on lines 40..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 268.

        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

                Context("Given multiple key=value pairs with prefix and suffic space", func() {
                    It("Should return the next token found in the buffer without the spaces", func() {
                        tokenizer := args.NewKeyValueTokenizer("key =value , key2= value2")
        
                        Expect(tokenizer.Next()).To(Equal("key"))
        Severity: Major
        Found in tokenizer_test.go and 1 other location - About 3 hrs to fix
        tokenizer_test.go on lines 24..39

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

        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 main has 106 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func main() {
            var conf Config
        
            // Create the parser with program name 'example'
            // and environment variables prefixed with APP_
        Severity: Major
        Found in examples/demo/demo.go - About 3 hrs to fix

          Method ArgParser.Watch has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
          Open

          func (self *ArgParser) Watch(backend Backend, callBack func(*ChangeEvent, error)) WatchCancelFunc {
              var isRunning sync.WaitGroup
              var once sync.Once
              done := make(chan struct{})
          
          
          Severity: Minor
          Found in backends.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

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

              Describe("IsDefault()", func() {
                  It("Should return true if the option used the default value", func() {
                      cmdLine := []string{"--two", "2"}
                      parser := args.NewParser()
                      parser.AddOption("--one").IsInt().Default("1")
          Severity: Major
          Found in options_test.go and 1 other location - About 2 hrs to fix
          options_test.go on lines 143..157

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

          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

              Describe("IsArg()", func() {
                  It("Should return true if the option as set via the command line", func() {
                      cmdLine := []string{"--two", "2"}
                      parser := args.NewParser()
                      parser.AddOption("--one").IsInt().Default("1")
          Severity: Major
          Found in options_test.go and 1 other location - About 2 hrs to fix
          options_test.go on lines 173..186

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

          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

          RuleModifier has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type RuleModifier struct {
              rule   *Rule
              parser *ArgParser
          }
          Severity: Minor
          Found in rule_modifier.go - About 2 hrs to fix

            Function WatchFile has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
            Open

            func WatchFile(path string, interval time.Duration, callBack func(error)) (WatchCancelFunc, error) {
                var isRunning sync.WaitGroup
                fsWatch, err := fsnotify.NewWatcher()
                if err != nil {
                    return nil, err
            Severity: Minor
            Found in watchfile.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

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

                        parser.AddCommand("set", func(parent *args.ArgParser, data interface{}) (int, error) {
                            parent.AddArgument("first").Required()
                            _, err := parent.Parse(nil)
                            Expect(err).To(Not(BeNil()))
                            Expect(err.Error()).To(Equal("User asked for help; Inspect this error " +
            Severity: Major
            Found in parser_test.go and 1 other location - About 2 hrs to fix
            parser_test.go on lines 710..721

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

            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

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

                        parser.AddCommand("set", func(parent *args.ArgParser, data interface{}) (int, error) {
                            parent.AddArgument("first").Required()
                            _, err := parent.Parse(nil)
                            Expect(err).To(Not(BeNil()))
                            Expect(err.Error()).To(Equal("User asked for help; Inspect this error " +
            Severity: Major
            Found in parser_test.go and 1 other location - About 2 hrs to fix
            parser_test.go on lines 683..694

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

            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

                    Context("Given a single key=value pair", func() {
                        It("Should return the next token found in the buffer", func() {
                            tokenizer := args.NewKeyValueTokenizer("key=value")
            
                            Expect(tokenizer.Next()).To(Equal("key"))
            Severity: Major
            Found in tokenizer_test.go and 1 other location - About 1 hr to fix
            tokenizer_test.go on lines 77..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 168.

            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

                    Context(`Given an escaped escaped delimiter key\\=value`, func() {
                        It("Should respect the escaped escaped delimiter", func() {
                            tokenizer := args.NewKeyValueTokenizer(`key\\=value`)
            
                            Expect(tokenizer.Next()).To(Equal(`key\\`))
            Severity: Major
            Found in tokenizer_test.go and 1 other location - About 1 hr to fix
            tokenizer_test.go on lines 12..23

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

            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

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

                    It("Should ensure []string provided is set when a comma separated list is provided", func() {
                        parser := args.NewParser()
                        var list []string
                        parser.AddOption("--list").StoreStringSlice(&list)
            
            
            Severity: Major
            Found in rule_modifier_test.go and 1 other location - About 1 hr to fix
            rule_modifier_test.go on lines 260..270

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

            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

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

                    It("Should ensure []string provided is set when a comma separated list is provided", func() {
                        parser := args.NewParser()
                        var list []string
                        parser.AddOption("--list").StoreStringSlice(&list)
            
            
            Severity: Major
            Found in rule_modifier_test.go and 1 other location - About 1 hr to fix
            rule_modifier_test.go on lines 272..282

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

            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