Showing 177 of 177 total issues
Method receive
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def receive(incoming_events)
tweets = tweets_from_events(incoming_events)
begin
twitter.favorite(tweets) if favorite?
- 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 handle_data
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_data(body, url, existing_payload)
# Beware, url may be a URI object, string or nil
doc = parse(body)
Function showCorrectRegionsOnStartup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
showCorrectRegionsOnStartup() {
if ($(".schedule-region")) {
if ($(".schedule-region").data("can-be-scheduled") === true) {
this.showSchedule();
} else {
Method schedule_scheduler_agent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def schedule_scheduler_agent(agent)
job = scheduler_agent_job(agent)
if agent.unavailable?
if job
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
attrs = agent_params
if agent = current_user.agents.find_by(id: params[:agent_id])
# POST /agents/:id/dry_run
if attrs.present?
Method json_serialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def json_serialize(*fields)
fields.each do |field|
class_eval <<-CODE
serialize :#{field}, JsonWithIndifferentAccess
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($(".control-link-region")) {
if (
$(".control-link-region").data("can-control-other-agents") === true
) {
this.showControlLinks();
- 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 58.
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
if ($(".schedule-region")) {
if ($(".schedule-region").data("can-be-scheduled") === true) {
this.showSchedule();
} else {
this.hideSchedule();
- 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 58.
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
if ($(".link-region")) {
if ($(".link-region").data("can-receive-events") === true) {
this.showLinks();
} else {
this.hideLinks();
- 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 58.
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_issues
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_issues(since)
startAt = 0
issues = []
# JQL doesn't have an ability to specify timezones
Method extract_xml
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extract_xml(doc)
extract_each { |extraction_details, values|
case
when css = extraction_details['css']
nodes = doc.css(css)
Method receive
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def receive(incoming_events)
# if there are too many, dump a bunch to avoid getting rate limited
if incoming_events.count > 20
incoming_events = incoming_events.first(20)
end
Method sortable_column
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sortable_column(attribute, default_direction = nil, options = nil)
if options.nil? && (options = Hash.try_convert(default_direction))
default_direction = nil
end
default_direction ||= 'desc'
- 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 diff_with!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def diff_with!(agent)
return unless agent.present?
self.agent = agent
- 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 validate_email_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_email_options
errors.add(
:base,
"subject and expected_receive_period_in_days are required"
) unless options['subject'].present? && options['expected_receive_period_in_days'].present?
- 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 receive
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def receive(incoming_events)
# if there are too many, dump a bunch to avoid getting rate limited
if incoming_events.count > 20
incoming_events = incoming_events.first(20)
end
- 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 receive
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def receive(incoming_events)
memory['pending_calls'] ||= {}
interpolate_with_each(incoming_events) do |event|
message = (event.payload['message'].presence || event.payload['text'].presence || event.payload['sms'].presence).to_s
if message.present?
- 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 check
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check
last_message = memory['last_message']
mqtt_client.connect
poll_thread = Thread.new do
- 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 included
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.included(mod)
mod.module_exec do
include HasAuthors
include HasEnclosure
include HasLinks
- 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 working?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def working?
return false if recent_error_logs?
if interpolated['expected_update_period_in_days'].present?
return false unless event_created_within?(interpolated['expected_update_period_in_days'])
- 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"