iainbeeston/nickel

View on GitHub

Showing 36 of 103 total issues

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

      def interpret(str, current_date)
        day_str, month_str, year_str = nil, nil, nil
        ambiguous = { month: false, year: false }   # assume false, we use this flag if we aren't certain about the year

        # appropriate matches
Severity: Minor
Found in lib/nickel/zdate.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 interpret has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def interpret(str, current_date)
        day_str, month_str, year_str = nil, nil, nil
        ambiguous = { month: false, year: false }   # assume false, we use this flag if we aren't certain about the year

        # appropriate matches
Severity: Minor
Found in lib/nickel/zdate.rb - About 1 hr to fix

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

        def initialize_sorted_time_map
          # Sorted time map has date/datespan/recurrence construct indices as keys, and
          # an array of time/timespan indices as values.
          @sorted_time_map = {}
    
    
    Severity: Minor
    Found in lib/nickel/construct_interpreter.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 extract_message has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def extract_message
          # message could be all components put back together (which would be @nlp_query), so start with that
          message_array = @nlp_query.split
          constructs = @construct_finder.constructs
    
    
    Severity: Minor
    Found in lib/nickel/nlp.rb - About 1 hr to fix

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

          def nsub!(*args)
            if m = query_str.match(args[0])    # m will now hold the FIRST set of backreferenced matches
              # there is at least one match
              @changed_in ||= []
              @changed_in << caller[1][/(\w+)\W*$/, 1]
      Severity: Minor
      Found in lib/nickel/nlp_query.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

      Method am_pm_modifier has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def am_pm_modifier(*time_array)
              # find firm time indices
              firm_time_indices = []
              time_array.each_with_index { |t, i| firm_time_indices << i if t.firm }
      
      
      Severity: Minor
      Found in lib/nickel/ztime.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

                  base_opts[:start_date] = case @constructs[wi].wrapper_type
                                           when 2 then base_opts[:end_date].sub_days(@constructs[wi].wrapper_length)
                                           when 3 then base_opts[:end_date].sub_weeks(@constructs[wi].wrapper_length)
                                           when 4 then base_opts[:end_date].sub_months(@constructs[wi].wrapper_length)
                                           end
      Severity: Major
      Found in lib/nickel/construct_interpreter.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if match_this_dayname
                  found_this_dayname                              # this fri
                elsif match_this_week
                  found_this_week                                 # this week
                elsif match_this_month
        Severity: Major
        Found in lib/nickel/construct_finder.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                elsif match_next
                  if match_next_weekend
                    found_next_weekend                              # next weekend --- never hit?
                  elsif match_next_dayname
                    found_next_dayname                              # next tuesday
          Severity: Major
          Found in lib/nickel/construct_finder.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if match_repeats_altmonthly_daymonthly
                        found_repeats_altmonthly_daymonthly           # repeats altmonthly 1st fri
                      elsif match_repeats_altmonthly_datemonthly
                        found_repeats_altmonthly_datemonthly          # repeats altmonthly 22nd
                      end
            Severity: Major
            Found in lib/nickel/construct_finder.rb - About 45 mins to fix

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

                    def interpret(str)
                      a_b   = /^(\d{1,4})(am|pm)?$/                     # handles cases (a) and (b)
                      c_d_e = /^(\d{1,2}):(\d{1,2})(am|pm)?$/           # handles cases (c), (d), and (e)
                      if mdata = str.match(a_b)
                        am_pm = mdata[2]
              Severity: Minor
              Found in lib/nickel/ztime.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

              Avoid deeply nested control flow statements.
              Open

                      elsif match_repeats_threemonthly
                        if match_repeats_threemonthly_daymonthly
                          found_repeats_threemonthly_daymonthly         # repeats threemonthly 1st fri
                        elsif match_repeats_threemonthly_datemonthly
                          found_repeats_threemonthly_datemonthly        # repeats threemonthly 22nd
              Severity: Major
              Found in lib/nickel/construct_finder.rb - About 45 mins to fix

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

                    def adjust_for(am_pm)
                      # how does validation work?  Well, we already know that @time is valid, and once we modify we call time= which will
                      # perform validation on the new time.  That won't catch something like this though:  ZTime.new("2215", :am)
                      # so we will check for that here.
                      # If user is providing :am or :pm, the hour must be between 1 and 12
                Severity: Minor
                Found in lib/nickel/ztime.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 finalize_timespan_constructs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def finalize_timespan_constructs(guess = false)
                      @tsci.each do |i|
                        st, et = @constructs[i].start_time, @constructs[i].end_time
                        if st.firm && et.firm
                          next  # nothing to do if start and end times are both firm
                Severity: Minor
                Found in lib/nickel/construct_interpreter.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 get_next_date_from_date_of_month has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_next_date_from_date_of_month(date_of_month)
                      o = dup
                      if day == date_of_month
                        o
                      else
                Severity: Minor
                Found in lib/nickel/zdate.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 create_occurrence_for_each_time_in_time_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def create_occurrence_for_each_time_in_time_map(occ_base, dindex, &block)
                      if !@sorted_time_map[dindex].empty?
                        @sorted_time_map[dindex].each do |tindex|   # tindex may be time index or time span index
                          occ = occ_base.dup
                          occ.start_time = start_time_from_tindex(tindex)
                Severity: Minor
                Found in lib/nickel/construct_interpreter.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