Showing 219 of 219 total issues
MeetupFetcher::Generator#generateEventDocument calls 'event['time']' 2 times Open
doc.data['dateStart'] = convertDate(event['time'],event['utc_offset'])
if event['duration']
doc.data['dateEnd'] = convertDate(event['time']+event['duration'],event['utc_offset'])
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
MeetupFetcher::Generator#generateEventDocument calls 'event['venue']' 3 times Open
if event['venue']
doc.data['location'] = "#{event['venue']['name']}<br>#{event['venue']['address_1']}"
- Read upRead up
- Exclude checks
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
Reek implements a check for Duplicate Method Call.
Example
Here's a very much simplified and contrived example. The following method will report a warning:
def double_thing()
@other.thing + @other.thing
end
One quick approach to silence Reek would be to refactor the code thus:
def double_thing()
thing = @other.thing
thing + thing
end
A slightly different approach would be to replace all calls of double_thing
by calls to @other.double_thing
:
class Other
def double_thing()
thing + thing
end
end
The approach you take will depend on balancing other factors in your code.
Jekyll::TimeFilter has no descriptive comment Open
module TimeFilter
- Read upRead up
- Exclude checks
Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.
Example
Given
class Dummy
# Do things...
end
Reek would emit the following warning:
test.rb -- 1 warning:
[1]:Dummy has no descriptive comment (IrresponsibleModule)
Fixing this is simple - just an explaining comment:
# The Dummy class is responsible for ...
class Dummy
# Do things...
end
Method getMeetUpGroupEvents
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def getMeetUpGroupEvents(group)
maxRetryTimeout = 50
initialRetries = 5
begin
retries ||= initialRetries
- 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
MeetupFetcher::Generator#convertDate doesn't depend on instance state (maybe move it to another class?) Open
def convertDate(date, offset)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::IcsFilter#convert_to_crlf doesn't depend on instance state (maybe move it to another class?) Open
def convert_to_crlf(input)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::RegexFilter#replace_regex doesn't depend on instance state (maybe move it to another class?) Open
def replace_regex(input, reg_str, repl_str)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Method generate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate(site)
@site = site
@collection = @site.collections["events"]
MeetupClient.configure do |config|
- 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 split_string
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def split_string(input, length = 75, prepend = " ")
output = ""
splitLines = input.lines
splitLines.each do | line |
if line.bytesize <= length
- 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
Jekyll::IcsFilter#utf8_valid doesn't depend on instance state (maybe move it to another class?) Open
def utf8_valid(input)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TimeFilter#date_to_utc doesn't depend on instance state (maybe move it to another class?) Open
def date_to_utc(input)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::IcsFilter#generate_sequence doesn't depend on instance state (maybe move it to another class?) Open
def generate_sequence(time)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Complex method MeetupFetcher::Generator#getMeetUpGroupEvents (20.0) Open
def getMeetUpGroupEvents(group)
maxRetryTimeout = 50
initialRetries = 5
begin
retries ||= initialRetries
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
MeetupFetcher::Generator#generateEventDocument has the name 'generateEventDocument' Open
def generateEventDocument(event)
- Read upRead up
- Exclude checks
An Uncommunicative Method Name
is a method name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
MeetupFetcher::Generator#getMeetUpGroupEvents has the variable name 'maxRetryTimeout' Open
maxRetryTimeout = 50
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
MeetupFetcher::Generator#getMeetUpGroupEvents has the variable name 'initialRetries' Open
initialRetries = 5
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
MeetupFetcher::Generator#getMeetUpGroupEvents has the variable name 'e' Open
rescue Exception => e
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
Jekyll::IcsFilter#split_string has the variable name 'splitLines' Open
splitLines = input.lines
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
MeetupFetcher::Generator#convertDate has the variable name 'convertedDate' Open
convertedDate = "#{DateTime.strptime(dateWithOffset.to_s,'%Q').strftime('%Y-%m-%d %H:%M:%S')} #{@@timezone}"
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
MeetupFetcher::Generator#generate has the variable name 'keyPath' Open
keyPath = "#{@site.source}/meetup_api_key"
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.