Showing 36 of 103 total issues
Class ConstructFinder
has 204 methods (exceeds 20 allowed). Consider refactoring. Open
class ConstructFinder
attr_reader :constructs, :components
def initialize(query, curdate, curtime)
@curdate = curdate
Method big_if_on_current_word
has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring. Open
def big_if_on_current_word
reset_instance_vars
if match_every
if match_every_dayname
- Read upRead up
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
File construct_finder.rb
has 984 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'nickel/construct'
require 'nickel/zdate'
require 'nickel/ztime'
module Nickel
File nlp_query.rb
has 656 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'nickel/zdate'
require 'nickel/ztime'
require 'nickel/nlp_query_constants'
module Nickel
Method standardize_input
has 273 lines of code (exceeds 25 allowed). Consider refactoring. Open
def standardize_input
nsub!(/last\s+#{DAY_OF_WEEK}/, '5th \1') # last dayname => 5th dayname
nsub!(/\ba\s+(week|month|day)/, '1 \1') # a month|week|day => 1 month|week|day
nsub!(/^(through|until)/, 'today through') # ^through => today through
nsub!(/every\s*(night|morning)/, 'every day')
Class ZDate
has 66 methods (exceeds 20 allowed). Consider refactoring. Open
class ZDate
include Comparable
@days_of_week = %w(mon tue wed thu fri sat sun)
@full_days_of_week = %w(monday tuesday wednesday thursday friday saturday sunday)
Method big_if_on_current_word
has 234 lines of code (exceeds 25 allowed). Consider refactoring. Open
def big_if_on_current_word
reset_instance_vars
if match_every
if match_every_dayname
Method standardize_numbers
has 202 lines of code (exceeds 25 allowed). Consider refactoring. Open
def standardize_numbers
nsub!(/\bone\s*-?\s*hundred\b/, '100')
nsub!(/\bone\s*-?\s*hundredth\b/, '100th')
nsub!(/\bninety\s*-?\s*nine\b/, '99')
nsub!(/\bninety\s*-?\s*ninth\b/, '99th')
Method standardize_input
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def standardize_input
nsub!(/last\s+#{DAY_OF_WEEK}/, '5th \1') # last dayname => 5th dayname
nsub!(/\ba\s+(week|month|day)/, '1 \1') # a month|week|day => 1 month|week|day
nsub!(/^(through|until)/, 'today through') # ^through => today through
nsub!(/every\s*(night|morning)/, 'every day')
- Read upRead up
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 ZTime
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class ZTime
include Comparable
# \@firm will be used to indicate user provided am/pm
attr_accessor :firm
File zdate.rb
has 416 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'date'
module Nickel
# TODO: get methods should accept dayname or dayindex
class ZDate
Method occ_base_opts_from_wrappers
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def occ_base_opts_from_wrappers
base_opts = {}
# Must do type 0 and 1 wrappers first, imagine something like
# "every friday starting next friday for 6 months".
@wci.each do |wi|
- Read upRead up
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 a Cognitive Complexity of 22 (exceeds 5 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
- Read upRead up
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 ConstructInterpreter
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ConstructInterpreter
attr_reader :occurrences, :constructs, :curdate
def initialize(constructs, curdate)
@constructs = constructs
File ztime.rb
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'time'
module Nickel
class ZTime
include Comparable
Method get_date_from_day_and_week_of_month
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_date_from_day_and_week_of_month(day_num, week_num)
# This method is extremely sloppy, clean it up
# Get the index of the first day of this month
first_day_of_month = beginning_of_month
first_day_index = first_day_of_month.dayindex
- Read upRead up
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 modify_such_that_is_before
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def modify_such_that_is_before(time2)
fail 'ZTime#modify_such_that_is_before says: trying to modify time that has @firm set' if @firm
fail 'ZTime#modify_such_that_is_before says: time2 does not have @firm set' unless time2.firm
# self cannot have @firm set, so all hours will be between 1 and 12
# time2 is an end time, self could be its current setting, or off by 12 hours
- Read upRead up
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 modify_such_that_is_after
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def modify_such_that_is_after(time1)
fail 'ZTime#modify_such_that_is_after says: trying to modify time that has @firm set' if @firm
fail 'ZTime#modify_such_that_is_after says: time1 does not have @firm set' unless time1.firm
# time1 to self --> time1 to self
# 8pm to 835 --> 2000 to 835
- Read upRead up
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 occ_base_opts_from_wrappers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def occ_base_opts_from_wrappers
base_opts = {}
# Must do type 0 and 1 wrappers first, imagine something like
# "every friday starting next friday for 6 months".
@wci.each do |wi|
Method get_date_from_day_and_week_of_month
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_date_from_day_and_week_of_month(day_num, week_num)
# This method is extremely sloppy, clean it up
# Get the index of the first day of this month
first_day_of_month = beginning_of_month
first_day_index = first_day_of_month.dayindex