Showing 231 of 231 total issues
Method has too many lines. [55/30] Open
def query(options = {})
data_labels = %w(
author_reputation percent_steem_dollars promoted category net_votes
total_pending_payout_value
)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [45/30] Open
def index
@request_at = Time.now
@activity_after = Time.parse(params[:activity_after].presence || '1970-01-01T00:00:00Z')
@activity_before = Time.parse(params[:activity_before].presence || @request_at.to_s)
@op = params[:op].presence || nil
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [45/30] Open
def other_promoted
@limit = @limit.to_i
response = api_execute(:get_account_history, 'null', -@limit, @limit)
history = response.result
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method other_promoted
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def other_promoted
@limit = @limit.to_i
response = api_execute(:get_account_history, 'null', -@limit, @limit)
history = response.result
- 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 accounts_controller.rb
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'open-uri'
require 'json'
class AccountsController < ApplicationController
before_action :prune_account_votes_cache
Class AccountsController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class AccountsController < ApplicationController
before_action :prune_account_votes_cache
helper_method :suggested_voters, :votes_today, :accounts
def index
Method index
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def index
@request_at = Time.now
@activity_after = Time.parse(params[:activity_after].presence || '1970-01-01T00:00:00Z')
@activity_before = Time.parse(params[:activity_before].presence || @request_at.to_s)
@op = params[:op].presence || nil
- 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
Cyclomatic complexity for index is too high. [14/6] Open
def index
@request_at = Time.now
@activity_after = Time.parse(params[:activity_after].presence || '1970-01-01T00:00:00Z')
@activity_before = Time.parse(params[:activity_before].presence || @request_at.to_s)
@op = params[:op].presence || nil
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Similar blocks of code found in 2 locations. Consider refactoring. Open
def accounts_created
@days = (params[:days] || '14.0').to_f
@segments = params[:segments] || 'default'
@average = 0
@style = params[:style] || 'default'
- 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 94.
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 2 locations. Consider refactoring. Open
def accounts_last_bandwidth_updated
@days = (params[:days] || '14.0').to_f
@segments = params[:segments] || 'default'
@average = 0
@style = params[:style] || 'default'
- 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 94.
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 has too many lines. [37/30] Open
def capture_chart(pair)
fmt = params[:format]
base_href = "https://www.worldcoinindex.com"
btc_usd = "#{base_href}/widget/renderWidget?size=large&from=BTC&to=usd&clearstyle=true&ms5=#{md5_title}"
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method query
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def query(options = {})
data_labels = %w(
author_reputation percent_steem_dollars promoted category net_votes
total_pending_payout_value
)
- 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
Cyclomatic complexity for net_transfers is too high. [12/6] Open
def net_transfers
@compare_to = params[:compare_to]
@account_name = params[:account_name]
@days = (params[:days] || '14.0').to_f
@symbol = params[:symbol] || default_debt_asset
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Cyclomatic complexity for query is too high. [12/6] Open
def query(options = {})
data_labels = %w(
author_reputation percent_steem_dollars promoted category net_votes
total_pending_payout_value
)
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method query
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def query(options = {})
options[:limit] ||= 100
tag = options[:tag]
flagged_by = options.delete(:flagged_by) || []
by_trending = discussions_by_trending(options)
- 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 query
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def query(options = {})
data_labels = %w(
author_reputation percent_steem_dollars promoted category net_votes
total_pending_payout_value
)
Cyclomatic complexity for discussion_active_class is too high. [10/6] Open
def discussion_active_class(current_tab, classes = [])
classes << case [current_tab, TRUE_STRING]
when [:other_promoted, @other_promoted] then 'active'
when [:predicted, @predicted] then 'active'
when [:trending, @trending_by_reputation] then 'active'
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Cyclomatic complexity for discussion_title is too high. [10/6] Open
def discussion_title
title = 'Gamymede - '
title << case TRUE_STRING
when @other_promoted then 'Promoted by Third Parties'
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Cyclomatic complexity for group_pattern is too high. [10/6] Open
def group_pattern(discussion)
case TRUE_STRING
when @other_promoted
[time_ago_in_words(discussion[:timestamp]), discussion[:from], discussion[:amount]]
when @predicted
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method query
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def query(options = {})
options[:limit] ||= 100
tag = options[:tag]
by_cashout = discussions_by_cashout(tag, options)
- 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"