trombik/qansible

View on GitHub

Showing 26 of 26 total issues

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

      def colorize(text, color = "default", bgcolor = "default")
        return text unless tty?

        colors = {
          "default" => "38",
Severity: Major
Found in lib/qansible/checks/base_check.rb and 1 other location - About 3 hrs to fix
lib/qansible/commands/base.rb on lines 55..102

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

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

      def colorize(text, color = "default", bgcolor = "default")
        return text unless tty?

        colors = {
          "default" => "38",
Severity: Major
Found in lib/qansible/commands/base.rb and 1 other location - About 3 hrs to fix
lib/qansible/checks/base_check.rb on lines 118..165

Duplicated Code

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

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

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

Tuning

This issue has a mass of 118.

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 colorize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def colorize(text, color = "default", bgcolor = "default")
        return text unless tty?

        colors = {
          "default" => "38",
Severity: Minor
Found in lib/qansible/checks/base_check.rb - About 1 hr to fix

    Method colorize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def colorize(text, color = "default", bgcolor = "default")
            return text unless tty?
    
            colors = {
              "default" => "38",
    Severity: Minor
    Found in lib/qansible/commands/base.rb - About 1 hr to fix

      Method must_accept_test_as_target has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def must_accept_test_as_target
              command = "rake -T"
              Dir.chdir(Qansible::Check::Base.root) do
                Open3.popen3(command) do |_stdin, stdout, stderr, process|
                  status = process.value.exitstatus
      Severity: Minor
      Found in lib/qansible/checks/rakefile.rb - 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

      Method should_have_tasks_with_verbs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def should_have_tasks_with_verbs
              verbs = %w[
                accept add apply archive ask assert bind boot bring build check clean
                clone collect commit configure copy correct create deal delete
                destroy detect disable do download dump dump enable ensure exclude
      Severity: Minor
      Found in lib/qansible/checks/tasks.rb - 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

      Method parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.parse(options)
              args = Qansible::Option::Init.new
              args.directory = Pathname.pwd
              args.verbose = false
              args.box_name = "trombik/ansible-freebsd-12.0-amd64"
      Severity: Minor
      Found in lib/qansible/parsers/init.rb - About 1 hr to fix

        Method should_have_tasks_with_verbs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def should_have_tasks_with_verbs
                verbs = %w[
                  accept add apply archive ask assert bind boot bring build check clean
                  clone collect commit configure copy correct create deal delete
                  destroy detect disable do download dump dump enable ensure exclude
        Severity: Minor
        Found in lib/qansible/checks/tasks.rb - About 1 hr to fix

          Method run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def run
                  raise RoleExist, "Directory `%s` already exists" % [dest_directory] if File.exist?(dest_directory)
          
                  Dir.mkdir(dest_directory)
                  Dir.chdir(dest_directory) do
          Severity: Minor
          Found in lib/qansible/commands/init.rb - About 1 hr to fix

            Method should_have_templates_with_validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def should_have_templates_with_validate
                    @task_yaml_content.each_key do |file|
                      yaml = @task_yaml_content[file]
                      next unless yaml
            
            
            Severity: Minor
            Found in lib/qansible/checks/tasks.rb - 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

            Method should_have_required_sections_at_level_one has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def should_have_required_sections_at_level_one
                    warnings = []
                    File.open(@@root + @path, "r") do |f|
                      f.each_line do |line|
                        next unless line =~ /^##+\s+(.*)/
            Severity: Minor
            Found in lib/qansible/checks/readme.rb - 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

            Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def run
                    Dir.mktmpdir do |d|
                      tmpdir = Pathname.new(d)
                      warnings = 0
                      create_reference_tree(tmpdir)
            Severity: Minor
            Found in lib/qansible/commands/qa.rb - About 1 hr to fix

              Method must_have_mandatory_keys_in_galaxy_info has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def must_have_mandatory_keys_in_galaxy_info
                      load_yaml unless @yaml
                      mandatory_keys = %w[
                        author
                        company
              Severity: Minor
              Found in lib/qansible/checks/meta_main_yml.rb - About 1 hr to fix

                Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def initialize(opts = {})
                        raise ArgumentError, "BUG: child class passed `%s`, instead of Hash" % [opts.class] unless opts.is_a?(Hash)
                
                        valid_options = [
                          :path
                Severity: Minor
                Found in lib/qansible/checks/base_check.rb - About 55 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 should_have_tasks_with_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def should_have_tasks_with_name
                        exceptions = %w[
                          assert
                          block
                          debug
                Severity: Minor
                Found in lib/qansible/checks/tasks.rb - About 55 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

                      def should_not_have_dash_as_heading
                        line_numbers = []
                        File.open(@@root + @path, "r") do |f|
                          f.each_line do |line|
                            line_numbers << f.lineno if line =~ /^---*\s*$/
                Severity: Minor
                Found in lib/qansible/checks/readme.rb and 1 other location - About 45 mins to fix
                lib/qansible/checks/readme.rb on lines 40..52

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

                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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def run
                        Dir.mktmpdir do |d|
                          tmpdir = Pathname.new(d)
                          warnings = 0
                          create_reference_tree(tmpdir)
                Severity: Minor
                Found in lib/qansible/commands/qa.rb - About 45 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 should_have_tasks_with_capitalized_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def should_have_tasks_with_capitalized_name
                        @task_yaml_content.each_key do |file|
                          yaml = @task_yaml_content[file]
                          next unless yaml
                
                
                Severity: Minor
                Found in lib/qansible/checks/tasks.rb - About 45 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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def run
                        raise RoleExist, "Directory `%s` already exists" % [dest_directory] if File.exist?(dest_directory)
                
                        Dir.mkdir(dest_directory)
                        Dir.chdir(dest_directory) do
                Severity: Minor
                Found in lib/qansible/commands/init.rb - About 45 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

                      def should_not_have_equal_as_heading_two
                        line_numbers = []
                        File.open(@@root + @path, "r") do |f|
                          f.each_line do |line|
                            line_numbers << f.lineno if line =~ /^===*\s*$/
                Severity: Minor
                Found in lib/qansible/checks/readme.rb and 1 other location - About 45 mins to fix
                lib/qansible/checks/readme.rb on lines 25..37

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

                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