piotrmurach/tty

View on GitHub

Showing 10 of 10 total issues

Class Add has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Add < TTY::Cmd
      include PathHelpers

      attr_reader :app_name

Severity: Minor
Found in lib/tty/commands/add.rb - About 4 hrs to fix

    Method execute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def execute(input: $stdin, output: $stdout)
            validate_pwd
            validate_cmd_name(cmd_name)
    
            test_dir = (options["test"] == "rspec") || ::Dir.exist?("spec") ? "spec" : "test"
    Severity: Minor
    Found in lib/tty/commands/add.rb - 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

    Method execute has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def execute(input: $stdin, output: $stdout)
            output.puts "OPTS: #{options}" if options["debug"]
    
            coc_opt  = options["coc"] ? "--coc" : "--no-coc"
            ext_opt  = options["ext"] ? "--ext" : "--no-ext"
    Severity: Minor
    Found in lib/tty/commands/new.rb - 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

    Method execute has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def execute(input: $stdin, output: $stdout)
            validate_pwd
            validate_cmd_name(cmd_name)
    
            test_dir = (options["test"] == "rspec") || ::Dir.exist?("spec") ? "spec" : "test"
    Severity: Major
    Found in lib/tty/commands/add.rb - About 2 hrs to fix

      File add.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "ostruct"
      
      require_relative "../cmd"
      require_relative "../templater"
      
      
      Severity: Minor
      Found in lib/tty/commands/add.rb - About 2 hrs to fix

        Method execute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def execute(input: $stdin, output: $stdout)
                output.puts "OPTS: #{options}" if options["debug"]
        
                coc_opt  = options["coc"] ? "--coc" : "--no-coc"
                ext_opt  = options["ext"] ? "--ext" : "--no-ext"
        Severity: Minor
        Found in lib/tty/commands/new.rb - About 1 hr to fix

          Method format_gem_dependencies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def format_gem_dependencies(dependencies = gemspec_dependencies)
                gems = []
                indent = " " * pre_var_indent
                dependencies.each do |gem|
                  if gem.comment
          Severity: Minor
          Found in lib/tty/gemspec.rb - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method cmd_desc_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def cmd_desc_args
                  return "" unless @options[:args].any?
          
                  " " + @options[:args].map do |arg|
                    if arg.start_with?("*")
          Severity: Minor
          Found in lib/tty/commands/add.rb - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

                    if !subcmd_exists?(content)
                      match = subcmd_matches.find { |m| content =~ m }
                      generator.inject_into_file(
                        cmd_file, "\n#{subcmd_template}",
                        **{after: match}.merge(file_options))
          Severity: Minor
          Found in lib/tty/commands/add.rb and 1 other location - About 15 mins to fix
          lib/tty/commands/add.rb on lines 122..126

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

          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

                    if !subcmd_registered?(cli_content)
                      match = register_subcmd_matches.find { |m| cli_content =~ m }
                      generator.inject_into_file(
                        cli_file, "\n#{register_subcmd_template}",
                        **{after: match}.merge(file_options))
          Severity: Minor
          Found in lib/tty/commands/add.rb and 1 other location - About 15 mins to fix
          lib/tty/commands/add.rb on lines 130..134

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

          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