thrawn01/args

View on GitHub

Showing 80 of 80 total issues

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

        It("Should set err if no option value is provided", func() {
            parser := args.NewParser()
            cmdLine := []string{"--power-level"}
            parser.AddOption("--power-level").IsInt()
            _, err := parser.Parse(&cmdLine)
Severity: Minor
Found in rule_modifier_test.go and 1 other location - About 40 mins to fix
rule_modifier_test.go on lines 168..175

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

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

        It("Should set err if no option value is provided", func() {
            parser := args.NewParser()
            cmdLine := []string{"--power-level"}
            parser.AddOption("--power-level").IsString()
            _, err := parser.Parse(&cmdLine)
Severity: Minor
Found in rule_modifier_test.go and 1 other location - About 40 mins to fix
rule_modifier_test.go on lines 134..142

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

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

Method ArgParser.parseUntil has 6 return statements (exceeds 4 allowed).
Open

func (self *ArgParser) parseUntil(terminator string) (*Options, error) {
    self.idx = 0

    // Sanity Check
    if len(self.rules) == 0 {
Severity: Major
Found in parser.go - About 40 mins to fix

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

    func StringToMap(value string) (map[string]string, error) {
        tokenizer := NewKeyValueTokenizer(value)
        result := make(map[string]string)
    
        var lvalue, rvalue, expression string
    Severity: Major
    Found in args.go - About 40 mins to fix

      Function castStringSlice has 5 return statements (exceeds 4 allowed).
      Open

      func castStringSlice(name string, dest interface{}, value interface{}) (interface{}, error) {
          // If our destination is nil, init a new slice
          if dest == nil {
              dest = make([]string, 0)
          }
      Severity: Major
      Found in args.go - About 35 mins to fix

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

                It("Should error if apply on map is invalid type", func() {
                    parser := args.NewParser()
                    parser.AddOption("--list").IsStringSlice()
        
                    options := parser.NewOptionsFromMap(
        Severity: Minor
        Found in parser_test.go and 1 other location - About 35 mins to fix
        parser_test.go on lines 308..318

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

        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

        Method Rule.GenerateUsage has 5 return statements (exceeds 4 allowed).
        Open

        func (self *Rule) GenerateUsage() string {
            switch {
            case self.Flags&IsOption != 0:
                if self.HasFlag(IsRequired) {
                    return fmt.Sprintf("%s", self.Aliases[0])
        Severity: Major
        Found in rules.go - About 35 mins to fix

          Function castBool has 5 return statements (exceeds 4 allowed).
          Open

          func castBool(name string, dest interface{}, value interface{}) (interface{}, error) {
              // If value is nil, return the type default
              if value == nil {
                  return false, nil
              }
          Severity: Major
          Found in args.go - About 35 mins to fix

            Function castStringMap has 5 return statements (exceeds 4 allowed).
            Open

            func castStringMap(name string, dest interface{}, value interface{}) (interface{}, error) {
                // If our destination is nil, init a new slice
                if dest == nil {
                    dest = make(map[string]string, 0)
                }
            Severity: Major
            Found in args.go - About 35 mins to fix

              Function createChickens has 5 return statements (exceeds 4 allowed).
              Open

              func createChickens(subParser *args.ArgParser, data interface{}) (int, error) {
                  subParser.AddArgument("name").Required().Help("The name of the chicken to create")
                  opts := subParser.ParseSimple(nil)
                  if opts == nil {
                      return 1, nil
              Severity: Major
              Found in examples/chicken-cli/checkin-cli.go - About 35 mins to fix

                Function WatchFile has 5 return statements (exceeds 4 allowed).
                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: Major
                Found in watchfile.go - About 35 mins to fix

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

                          It("Should error if apply on map is invalid type", func() {
                              parser := args.NewParser()
                              parser.AddOption("--map").IsStringMap()
                  
                              options := parser.NewOptionsFromMap(
                  Severity: Minor
                  Found in parser_test.go and 1 other location - About 35 mins to fix
                  parser_test.go on lines 192..202

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

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

                          It("Should create argument rule first", func() {
                              parser := args.NewParser()
                              parser.AddArgument("first").IsString()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("first"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 36..42
                  parser_test.go on lines 43..49
                  parser_test.go on lines 51..57
                  parser_test.go on lines 59..65
                  parser_test.go on lines 364..370

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

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

                          It("Should create optional rule ++one", func() {
                              parser := args.NewParser()
                              parser.AddOption("++one").Count()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("one"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 36..42
                  parser_test.go on lines 51..57
                  parser_test.go on lines 59..65
                  parser_test.go on lines 364..370
                  parser_test.go on lines 409..415

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

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

                          It("Should create optional rule -one", func() {
                              parser := args.NewParser()
                              parser.AddOption("-one").Count()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("one"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 36..42
                  parser_test.go on lines 43..49
                  parser_test.go on lines 59..65
                  parser_test.go on lines 364..370
                  parser_test.go on lines 409..415

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

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

                          It("Should create optional rule --one", func() {
                              parser := args.NewParser()
                              parser.AddOption("--one").Count()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("one"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 43..49
                  parser_test.go on lines 51..57
                  parser_test.go on lines 59..65
                  parser_test.go on lines 364..370
                  parser_test.go on lines 409..415

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

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

                          It("Should create optional rule +one", func() {
                              parser := args.NewParser()
                              parser.AddOption("+one").Count()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("one"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 36..42
                  parser_test.go on lines 43..49
                  parser_test.go on lines 51..57
                  parser_test.go on lines 364..370
                  parser_test.go on lines 409..415

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

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

                          It("Should create argument rule first", func() {
                              parser := args.NewParser()
                              parser.AddPositional("first").IsString()
                              rule := parser.GetRules()[0]
                              Expect(rule.Name).To(Equal("first"))
                  Severity: Major
                  Found in parser_test.go and 5 other locations - About 35 mins to fix
                  parser_test.go on lines 36..42
                  parser_test.go on lines 43..49
                  parser_test.go on lines 51..57
                  parser_test.go on lines 59..65
                  parser_test.go on lines 409..415

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

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

                          It("Should match first argument 'one'", func() {
                              parser := args.NewParser()
                              parser.AddArgument("first").IsString()
                              opt, err := parser.Parse(&cmdLine)
                              Expect(err).To(BeNil())
                  Severity: Major
                  Found in parser_test.go and 6 other locations - About 35 mins to fix
                  parser_test.go on lines 67..73
                  parser_test.go on lines 74..80
                  parser_test.go on lines 81..87
                  parser_test.go on lines 88..94
                  parser_test.go on lines 95..101
                  parser_test.go on lines 371..377

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

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

                          It("Should match -two", func() {
                              parser := args.NewParser()
                              parser.AddOption("-two").Count()
                              opt, err := parser.Parse(&cmdLine)
                              Expect(err).To(BeNil())
                  Severity: Major
                  Found in parser_test.go and 6 other locations - About 35 mins to fix
                  parser_test.go on lines 67..73
                  parser_test.go on lines 81..87
                  parser_test.go on lines 88..94
                  parser_test.go on lines 95..101
                  parser_test.go on lines 371..377
                  parser_test.go on lines 416..422

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

                  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