AndyObtiva/glimmer-dsl-libui

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

Summary

Maintainability
F
6 days
Test Coverage

File scaffold.rb has 631 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_window_file has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def custom_window_file(custom_window_name, namespace, window_type, window_options = {})
              window_options ||= {}
              window_options[:custom_window_class_name] ||= 'CustomWindow'
              namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
        
    Severity: Major
    Found in lib/glimmer/rake_task/scaffold.rb - About 5 hrs to fix

      Method custom_window_file has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

              def custom_window_file(custom_window_name, namespace, window_type, window_options = {})
                window_options ||= {}
                window_options[:custom_window_class_name] ||= 'CustomWindow'
                namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
          
      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

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

                def custom_window_gem(custom_window_name, namespace)
                  gem_name = "glimmer-libui-cw-#{custom_window_name.underscore}"
                  gem_summary = "#{human_name(custom_window_name)} - Glimmer Custom Window"
                  begin
                    custom_window_keyword = dsl_control_name(custom_window_name)
        Severity: Major
        Found in lib/glimmer/rake_task/scaffold.rb - About 2 hrs to fix

          Method custom_window_gem has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                  def custom_window_gem(custom_window_name, namespace)
                    gem_name = "glimmer-libui-cw-#{custom_window_name.underscore}"
                    gem_summary = "#{human_name(custom_window_name)} - Glimmer Custom Window"
                    begin
                      custom_window_keyword = dsl_control_name(custom_window_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 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def common_app(app_name, window_type = :app, window_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 "ruby -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 2 hrs to fix

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

                    def custom_shape_gem(custom_shape_name, namespace)
                      gem_name = "glimmer-libui-cs-#{custom_shape_name.underscore}"
                      gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                      if namespace
                        gem_name += "-#{namespace.underscore}"
            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_control_gem has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def custom_control_gem(custom_control_name, namespace)
                      gem_name = "glimmer-libui-cc-#{custom_control_name.underscore}"
                      gem_summary = "#{human_name(custom_control_name)} - Glimmer Custom Control"
                      if namespace
                        gem_name += "-#{namespace.underscore}"
            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 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Method custom_control_gem has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def custom_control_gem(custom_control_name, namespace)
                        gem_name = "glimmer-libui-cc-#{custom_control_name.underscore}"
                        gem_summary = "#{human_name(custom_control_name)} - Glimmer Custom Control"
                        if namespace
                          gem_name += "-#{namespace.underscore}"
              Severity: Minor
              Found in lib/glimmer/rake_task/scaffold.rb - About 1 hr to fix

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

                        def common_app(app_name, window_type = :app, window_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 "ruby -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 app_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        def app_model(current_dir_name, namespace = nil)
                          model_name = 'Greeting'
                          namespace ||= current_dir_name
                          root_dir = File.exist?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/model"
                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.exist?('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

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

                        def custom_control(custom_control_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exist?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_control_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_control_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_window has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        def custom_window(custom_window_name, namespace, window_type = nil, window_options = {})
                          namespace ||= current_dir_name
                          root_dir = File.exist?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_window_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_window_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_shape_gem(custom_shape_name, namespace)
                          gem_name = "glimmer-libui-cs-#{custom_shape_name.underscore}"
                          gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
                          if namespace
                            gem_name += "-#{namespace.underscore}"
                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 294..330

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

                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_control_gem(custom_control_name, namespace)
                          gem_name = "glimmer-libui-cc-#{custom_control_name.underscore}"
                          gem_summary = "#{human_name(custom_control_name)} - Glimmer Custom Control"
                          if namespace
                            gem_name += "-#{namespace.underscore}"
                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 333..369

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

                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_control(custom_control_name, namespace)
                          namespace ||= current_dir_name
                          root_dir = File.exist?('app') ? 'app' : 'lib'
                          parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
                          return puts("The file '#{parent_dir}/#{file_name(custom_control_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_control_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 212..218

                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.exist?('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 203..209

                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