AndyObtiva/glimmer-dsl-libui

View on GitHub

Showing 312 of 312 total issues

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

    def contact_for(index)
      number = index + 1
      first_name = NAMES_FIRST.sample
      last_name = NAMES_LAST.sample
      phone = 10.times.map { rand(10) }.yield_self { |numbers| [numbers[0..2], numbers[3..5], numbers[6..9]].map(&:join).join('-') }
Severity: Major
Found in examples/lazy_table.rb and 1 other location - About 1 hr to fix
examples/lazy_table3.rb on lines 42..49

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

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 contact_for(index)
      number = index + 1
      first_name = NAMES_FIRST.sample
      last_name = NAMES_LAST.sample
      phone = 10.times.map { rand(10) }.yield_self { |numbers| [numbers[0..2], numbers[3..5], numbers[6..9]].map(&:join).join('-') }
Severity: Major
Found in examples/lazy_table3.rb and 1 other location - About 1 hr to fix
examples/lazy_table.rb on lines 44..51

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

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

  def launch
    window('histogram example', 640, 480) {
      margined true
      
      horizontal_box {
Severity: Minor
Found in examples/histogram.rb - About 1 hr to fix

    Method interpret_color has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def interpret_color(value)
            if value.is_a?(Array) && value.last.is_a?(Hash)
              options = value.last
              value = value[0...-1]
            end
    Severity: Minor
    Found in lib/glimmer/libui.rb - About 1 hr to fix

      Method launch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def launch
          window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
            margined true
            
            area {
      Severity: Minor
      Found in examples/basic_draw_text2.rb - About 1 hr to fix

        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

        Method setup_timer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def setup_timer
            unless @setup_timer
              Glimmer::LibUI.timer(1) do
                if @started
                  seconds = @sec_spinbox.value
        Severity: Minor
        Found in examples/timer2.rb - About 1 hr to fix

          Method default_blocks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def default_blocks
                  case @letter
                  when :I
                    [
                      [block, block, block, block]
          Severity: Minor
          Found in examples/tetris/model/tetromino.rb - About 1 hr to fix

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

              def launch
                window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
                  margined true
                  
                  vertical_box {
            Severity: Minor
            Found in examples/custom_draw_text2.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 fill has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def fill(*args)
                      args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
                      if args.empty?
                        @fill ||= {}
                      else
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy/path_proxy.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 launch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def launch
                window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
                  margined true
                  
                  vertical_box {
            Severity: Minor
            Found in examples/custom_draw_text.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 stroke has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def stroke(*args)
                      args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
                      if args.empty?
                        @stroke ||= {}
                      else
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy/path_proxy.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 x has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def x(value = nil)
                      if value.nil?
                        @args.size > 3 ? @args[1] : (@options[:x] || 0)
                      else
                        if @args.size > 3
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy/image_proxy.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 method_missing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def method_missing(method_name, *args, &block)
                    method_name_parameter = method_name.to_s.sub(/=$/, '').sub(/^set_/, '').to_sym
                    if self.class.parameters.include?(method_name_parameter)
                      method_name = method_name.to_s
                      parameter_index = self.class.parameters.index(method_name_parameter)
            Severity: Minor
            Found in lib/glimmer/libui/shape.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 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 y has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def y(value = nil)
                      if value.nil?
                        @args.size > 3 ? @args[2] : (@options[:y] || 0)
                      else
                        if @args.size > 3
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy/image_proxy.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 resizable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def resizable(value = nil)
                      if value.nil?
                        @resizable = true if @resizable.nil?
                        @resizable
                      else
            Severity: Minor
            Found in lib/glimmer/libui/control_proxy/window_proxy.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 launch has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def launch
                window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
                  margined true
                  
                  area {
            Severity: Minor
            Found in examples/basic_draw_text.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language