brewster1134/cli_miami

View on GitHub

Showing 14 of 38 total issues

Method request_hash has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def request_hash options
    hash = {}
    options[:keys] ||= []
    value_options = CliMiami.get_options(options[:value_options] || {})
    required_keys_set = false
Severity: Minor
Found in lib/cli_miami/ask.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 request_multiple_choice has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def request_multiple_choice options
    selected_choices = nil
    selected_choice_indexes = []

    while selected_choice_indexes.length < options[:max]
Severity: Minor
Found in lib/cli_miami/ask.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 Validation has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class CliMiami::Validation
  attr_reader :error, :valid, :value

  # validates string provided by the user
  #
Severity: Minor
Found in lib/cli_miami/validation.rb - About 2 hrs to fix

    Method request_multiple_choice has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def request_multiple_choice options
        selected_choices = nil
        selected_choice_indexes = []
    
        while selected_choice_indexes.length < options[:max]
    Severity: Minor
    Found in lib/cli_miami/ask.rb - About 1 hr to fix

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

        def self.get_options user_options = {}
          # lookup preset if passed in as a symbol, or as a :preset key in an options hash
          if user_options.is_a? Hash
            user_options.deep_symbolize_keys!
            options = @@presets[user_options.delete(:preset)] || {}
      Severity: Minor
      Found in lib/cli_miami.rb - About 1 hr to fix

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

          def convert_type_to_string value
            case value
        
            when Array
              value.map do |e|
        Severity: Minor
        Found in lib/cli_miami/error.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 request_hash has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def request_hash options
            hash = {}
            options[:keys] ||= []
            value_options = CliMiami.get_options(options[:value_options] || {})
            required_keys_set = false
        Severity: Minor
        Found in lib/cli_miami/ask.rb - About 1 hr to fix

          Method request_until_valid has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def request_until_valid options, allow_empty_string = false
              response = nil
          
              while response.nil?
                # get user input based on given file type
          Severity: Minor
          Found in lib/cli_miami/ask.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 request_range has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def request_range options
              start_value = nil
              end_value = nil
              range_value_options = CliMiami.get_options type: :float
          
          
          Severity: Minor
          Found in lib/cli_miami/ask.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 request_array has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def request_array options
              array = []
              value_options = CliMiami.get_options(options[:value_options] || {})
          
              # build the array by prompting the user
          Severity: Minor
          Found in lib/cli_miami/ask.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 get_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.get_options user_options = {}
              # lookup preset if passed in as a symbol, or as a :preset key in an options hash
              if user_options.is_a? Hash
                user_options.deep_symbolize_keys!
                options = @@presets[user_options.delete(:preset)] || {}
          Severity: Minor
          Found in lib/cli_miami.rb - About 55 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

          Avoid deeply nested control flow statements.
          Open

                      if options[:keys].include? user_key
                        # prevent deleting required keys
                        CliMiami::S.ay I18n.t('cli_miami.errors.multiple_choice.delete_required_key', key: user_key), :cli_miami_fail
                        redo
                      else
          Severity: Major
          Found in lib/cli_miami/ask.rb - About 45 mins to fix

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

              def initialize initial_value, options
                @options = CliMiami.get_options options
                @value = initial_value
                @valid = true
                @error = nil
            Severity: Minor
            Found in lib/cli_miami/validation.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 validate_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def validate_hash hash, options
                hash.deep_symbolize_keys!
            
                validate_length hash, hash.keys.length, options
            
            
            Severity: Minor
            Found in lib/cli_miami/validation.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

            Severity
            Category
            Status
            Source
            Language