AndyObtiva/glimmer-dsl-swt

View on GitHub
lib/glimmer/rake_task/scaffold.rb

Summary

Maintainability
F
6 days
Test Coverage

File scaffold.rb has 617 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fileutils'
require 'os'
require 'facets/string/titlecase'

# TODO refactor to nest under RakeTask namespace
Severity: Major
Found in lib/glimmer/rake_task/scaffold.rb - About 1 day to fix

    Method custom_shell_file has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def custom_shell_file(custom_shell_name, namespace, shell_type, shell_options = {})
              namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
        
              custom_shell_file_content = <<-MULTI_LINE_STRING
    #{namespace_type} #{class_name(namespace)}
    Severity: Major
    Found in lib/glimmer/rake_task/scaffold.rb - About 5 hrs to fix

      Class Scaffold has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Scaffold
            class << self
              include FileUtils
          
              VERSION = File.read(File.expand_path('../../../../VERSION', __FILE__)).strip
      Severity: Minor
      Found in lib/glimmer/rake_task/scaffold.rb - About 3 hrs to fix

        Method custom_shell_file has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

                def custom_shell_file(custom_shell_name, namespace, shell_type, shell_options = {})
                  namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
            
                  custom_shell_file_content = <<-MULTI_LINE_STRING
        #{namespace_type} #{class_name(namespace)}
        Severity: Minor
        Found in lib/glimmer/rake_task/scaffold.rb - About 3 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 custom_shell_gem has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def custom_shell_gem(custom_shell_name, namespace)
                  gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
                  gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
                  begin
                    custom_shell_keyword = dsl_widget_name(custom_shell_name)
        Severity: Major
        Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs to fix

          Method custom_shell_gem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                  def custom_shell_gem(custom_shell_name, namespace)
                    gem_name = "glimmer-cs-#{compact_name(custom_shell_name)}"
                    gem_summary = "#{human_name(custom_shell_name)} - Glimmer Custom Shell"
                    begin
                      custom_shell_keyword = dsl_widget_name(custom_shell_name)
          Severity: Minor
          Found in lib/glimmer/rake_task/scaffold.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 common_app has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def common_app(app_name, shell_type = :app, shell_options = {})
                    gem_name = file_name(app_name)
                    gem_summary = human_name(app_name)
                    return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
                    system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
          Severity: Major
          Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs to fix

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

                    def custom_shape_gem(custom_shape_name, namespace)
                      gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
                      gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                      if namespace
                        gem_name += "-#{compact_name(namespace)}"
            Severity: Minor
            Found in lib/glimmer/rake_task/scaffold.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 common_app has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    def common_app(app_name, shell_type = :app, shell_options = {})
                      gem_name = file_name(app_name)
                      gem_summary = human_name(app_name)
                      return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
                      system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
            Severity: Minor
            Found in lib/glimmer/rake_task/scaffold.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 custom_widget_gem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                    def custom_widget_gem(custom_widget_name, namespace)
                      gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
                      gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
                      if namespace
                        gem_name += "-#{compact_name(namespace)}"
            Severity: Minor
            Found in lib/glimmer/rake_task/scaffold.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 custom_shape_gem has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def custom_shape_gem(custom_shape_name, namespace)
                      gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
                      gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                      if namespace
                        gem_name += "-#{compact_name(namespace)}"
            Severity: Minor
            Found in lib/glimmer/rake_task/scaffold.rb - About 1 hr to fix

              Method custom_widget_gem has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def custom_widget_gem(custom_widget_name, namespace)
                        gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
                        gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
                        if namespace
                          gem_name += "-#{compact_name(namespace)}"
              Severity: Minor
              Found in lib/glimmer/rake_task/scaffold.rb - About 1 hr to fix

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

                        def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
                          namespace ||= current_dir_name
                          root_dir = File.exists?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_shell_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shell_name)}.rb")
                Severity: Minor
                Found in lib/glimmer/rake_task/scaffold.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

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

                        def custom_widget(custom_widget_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exists?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
                Severity: Minor
                Found in lib/glimmer/rake_task/scaffold.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

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

                        def custom_shape(custom_shape_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exists?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_shape_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shape_name)}.rb")
                Severity: Minor
                Found in lib/glimmer/rake_task/scaffold.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

                        def custom_widget_gem(custom_widget_name, namespace)
                          gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
                          gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
                          if namespace
                            gem_name += "-#{compact_name(namespace)}"
                Severity: Major
                Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 4 hrs to fix
                lib/glimmer/rake_task/scaffold.rb on lines 349..385

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

                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

                        def custom_shape_gem(custom_shape_name, namespace)
                          gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
                          gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                          if namespace
                            gem_name += "-#{compact_name(namespace)}"
                Severity: Major
                Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 4 hrs to fix
                lib/glimmer/rake_task/scaffold.rb on lines 310..346

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

                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

                        def custom_widget(custom_widget_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exists?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
                Severity: Major
                Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 1 hr to fix
                lib/glimmer/rake_task/scaffold.rb on lines 227..233

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

                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

                        def custom_shape(custom_shape_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exists?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_shape_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shape_name)}.rb")
                Severity: Major
                Found in lib/glimmer/rake_task/scaffold.rb and 1 other location - About 1 hr to fix
                lib/glimmer/rake_task/scaffold.rb on lines 218..224

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

                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

                There are no issues that match your filters.

                Category
                Status