ShogunPanda/bovem

View on GitHub
lib/bovem/console.rb

Summary

Maintainability
C
1 day
Test Coverage

File console.rb has 349 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Bovem
  # List of valid terminal colors.
  TERM_COLORS = {black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7, default: 9}.freeze

  # List of valid terminal text effects.
Severity: Minor
Found in lib/bovem/console.rb - About 4 hrs to fix

    Method replace_markers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def replace_markers(message, plain = false)
              stack = []
    
              message.ensure_string.gsub(/((\{mark=([a-z\-_\s,]+)\})|(\{\/mark\}))/mi) do
                if $LAST_MATCH_INFO[1] == "{/mark}" # If it is a tag, pop from the latest opened.
    Severity: Minor
    Found in lib/bovem/console.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 validate_input_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_input_value(reply, validator)
            # Match against the validator
            if validator.present?
              if validator.is_a?(Array)
                reply = validate_array(reply, validator)
    Severity: Minor
    Found in lib/bovem/console.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 progress has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def progress(current, total, type: :list, precision: 0)
            if type == :list
              compute_list_progress(current, total)
            else
              precision = [0, precision].max
    Severity: Minor
    Found in lib/bovem/console.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 indent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def indent(message, width = true, newline_separator = "\n")
            if width.to_integer != 0
              width = (width.is_a?(TrueClass) ? 0 : width.to_integer)
              width = width < 0 ? -width : @indentation + width
    
    
    Severity: Minor
    Found in lib/bovem/console.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_input_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_input_value(prompt, echo, default_value = nil)
            if prompt
              Kernel.print(format(prompt, suffix: false, indented: false))
              $stdout.flush
            end
    Severity: Minor
    Found in lib/bovem/console.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 add_style has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def add_style(styles, plain, stack)
              styles = styles.ensure_string
              replacement = plain ? "" : Bovem::Console.parse_styles(styles)
    
              unless replacement.empty?
    Severity: Minor
    Found in lib/bovem/console.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 wrap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def wrap(message, width = nil)
            if width.to_integer <= 0
              message
            else
              width = (width == true || width.to_integer < 0 ? line_width : width.to_integer)
    Severity: Minor
    Found in lib/bovem/console.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 3 locations. Consider refactoring.
    Open

          def warn(message, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, print: true)
            info(
              message,
              suffix: suffix,
              indented: indented,
    Severity: Minor
    Found in lib/bovem/console.rb and 2 other locations - About 40 mins to fix
    lib/bovem/console.rb on lines 465..476
    lib/bovem/console.rb on lines 519..530

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

    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 3 locations. Consider refactoring.
    Open

          def debug(message, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, print: true)
            info(
              message,
              suffix: suffix,
              indented: indented,
    Severity: Minor
    Found in lib/bovem/console.rb and 2 other locations - About 40 mins to fix
    lib/bovem/console.rb on lines 492..503
    lib/bovem/console.rb on lines 519..530

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

    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 3 locations. Consider refactoring.
    Open

          def error(message, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, print: true)
            info(
              message,
              suffix: suffix,
              indented: indented,
    Severity: Minor
    Found in lib/bovem/console.rb and 2 other locations - About 40 mins to fix
    lib/bovem/console.rb on lines 465..476
    lib/bovem/console.rb on lines 492..503

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

    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