Showing 103 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def found_repeats_threemonthly_daymonthly
rep_array = [[@week_num, @day_index]] # That is NOT a typo
j = 4
while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
rep_array << [@week_num, @day_index]
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def found_repeats_daymonthly
rep_array = [[@week_num, @day_index]] # That is NOT a typo, not sure what I meant by that! maybe the nested array
j = 4
while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
rep_array << [@week_num, @day_index]
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def found_repeats_altmonthly_daymonthly
rep_array = [[@week_num, @day_index]]
j = 4
while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
rep_array << [@week_num, @day_index]
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"