gavinlaking/vedeu

View on GitHub

Showing 67 of 67 total issues

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

      def buffer
        empty = Array.new(Vedeu.height) { Array.new(Vedeu.width) { ' ' } }

        output.each do |row|
          row.each do |char|
Severity: Minor
Found in lib/vedeu/renderers/text.rb and 1 other location - About 50 mins to fix
lib/vedeu/renderers/escape.rb on lines 39..50

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

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 buffer
        empty = Array.new(Vedeu.height) { Array.new(Vedeu.width) { '[:cell]' } }

        output.each do |row|
          row.each do |char|
Severity: Minor
Found in lib/vedeu/renderers/escape.rb and 1 other location - About 50 mins to fix
lib/vedeu/renderers/text.rb on lines 34..45

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

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

      def add(name, focus = false)
        if registered?(name)
          return storage unless focus

          by_name(name)
Severity: Minor
Found in lib/vedeu/models/focus.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 stream has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def stream(value = '', opts = {}, &block)
        requires_model!

        attrs = build_attributes(value, opts, &block)

Severity: Minor
Found in lib/vedeu/dsl/elements.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 output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def output
        Vedeu.timer("Drawing border: '#{name}'") do
          [
            (top if top?),
            (left if left?),
Severity: Minor
Found in lib/vedeu/borders/refresh.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 bordered_width has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def bordered_width
        return width unless border && enabled?

        if left? && right?
          width - 2
Severity: Minor
Found in lib/vedeu/geometries/area/area.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 bordered_height has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def bordered_height
        return height unless border && enabled?

        if top? && bottom?
          height - 2
Severity: Minor
Found in lib/vedeu/geometries/area/area.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(argv   = [],
                   stdin  = STDIN,
                   stdout = STDOUT,
                   stderr = STDERR,
                   kernel = Kernel)
Severity: Minor
Found in lib/vedeu/runtime/launcher.rb - About 35 mins to fix

    Method build has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def self.build(context = nil,
                         model   = nil,
                         value   = '',
                         options = {},
                         &block)
    Severity: Minor
    Found in lib/vedeu/dsl/helpers/attributes.rb - About 35 mins to fix

      Method execute! has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def self.execute!(argv = [],
                            stdin  = STDIN,
                            stdout = STDOUT,
                            stderr = STDERR,
                            kernel = Kernel)
      Severity: Minor
      Found in lib/vedeu/runtime/launcher.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(context = nil,
                             model   = nil,
                             value   = '',
                             options = {},
                             &block)
        Severity: Minor
        Found in lib/vedeu/dsl/helpers/attributes.rb - About 35 mins to fix

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

            class XCoordinate
          
              # @param geometry [Vedeu::Geometries::Geometry]
              # @return [Vedeu::XCoordinate]
              def initialize(geometry)
          Severity: Minor
          Found in lib/vedeu/support/x_coordinate.rb and 1 other location - About 35 mins to fix
          lib/vedeu/support/y_coordinate.rb on lines 9..55

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

          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

            class YCoordinate
          
              # @param geometry [Vedeu::Geometries::Geometry]
              # @return [Vedeu::YCoordinate]
              def initialize(geometry)
          Severity: Minor
          Found in lib/vedeu/support/y_coordinate.rb and 1 other location - About 35 mins to fix
          lib/vedeu/support/x_coordinate.rb on lines 9..55

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

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

                def pair
                  if maximised?
                    [1, default]
          
                  elsif bottom_aligned? || right_aligned?
          Severity: Minor
          Found in lib/vedeu/geometries/area/dimension.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def switch_mode!(mode = nil)
                  if present?(mode) && valid_mode?(mode)
                    Vedeu.configure { |config| config.terminal_mode = mode }
          
                  else
          Severity: Minor
          Found in lib/vedeu/terminal/mode.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def coerce
                  raise Vedeu::Error::InvalidSyntax unless hash?(value)
          
                  if colour? && hash?(colour)
                    Vedeu::Coercers::ColourAttributes.coerce(colour)
          Severity: Minor
          Found in lib/vedeu/coercers/colour_attributes.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def stop
                  log('Attempting to stop')
          
                  return not_enabled unless Vedeu.config.drb?
          
          
          Severity: Minor
          Found in lib/vedeu/distributed/server.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def add_action(controller, action)
                  if present?(controller) && present?(action)
                    Vedeu.log(type:    :create,
                              message: "Action: ':#{action}' " \
                                       "(for ':#{controller}')")
          Severity: Minor
          Found in lib/vedeu/runtime/router.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def read
                  keys = console.getch
          
                  if keys.ord == Vedeu::ESCAPE_KEY_CODE
                    keys << console.read_nonblock(4) rescue nil
          Severity: Minor
          Found in lib/vedeu/input/raw.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

                def coerce
                  if coerced?
                    value
          
                  elsif value.is_a?(Vedeu::Models::Row)
          Severity: Minor
          Found in lib/vedeu/coercers/page.rb - About 35 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

          Severity
          Category
          Status
          Source
          Language