Method has too many lines. [22/10] Open
def summarize_reviews_by_reviewee(questions, assignment, reviewee_id, summary_ws_url, _session = nil)
self.summary = ({})
self.avg_scores_by_round = ({})
self.avg_scores_by_criterion = ({})
self.summary_ws_url = summary_ws_url
- 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.
Assignment Branch Condition size for summarize_reviews_by_reviewee is too high. [25.14/15] Open
def summarize_reviews_by_reviewee(questions, assignment, reviewee_id, summary_ws_url, _session = nil)
self.summary = ({})
self.avg_scores_by_round = ({})
self.avg_scores_by_criterion = ({})
self.summary_ws_url = summary_ws_url
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [13/10] Open
def calculate_avg_score_by_criterion(question_answers, q_max_score)
# get score and summary of answers for each question
# only include divide the valid_answer_sum with the number of valid answers
valid_answer_counter = 0
- 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.
Assignment Branch Condition size for calculate_round_score is too high. [18.19/15] Open
def calculate_round_score(avg_scores_by_criterion, criterions)
round_score = sum_weight = 0.0
# include this score in the average round score if the weight is valid & q is criterion
criterions = [*criterions]
criterions.each do |criteria|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [12/10] Open
def summarize_sentences(comments, summary_ws_url)
logger = Logger.new(STDOUT)
logger.level = Logger::WARN
param = { sentences: comments }
# call web service
- 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.
Assignment Branch Condition size for summarize_reviews_by_reviewee_question is too high. [16.28/15] Open
def summarize_reviews_by_reviewee_question(assignment, reviewee_id, question, round)
question_answers = Answer.answers_by_question_for_reviewee(assignment.id, reviewee_id, question.id)
avg_scores_by_criterion[round.to_s][question.txt] = calculate_avg_score_by_criterion(question_answers, get_max_score_for_question(question))
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method summarize_reviews_by_reviewee
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def summarize_reviews_by_reviewee(questions, assignment, reviewee_id, summary_ws_url, _session = nil)
Method summarize_reviews_by_reviewee
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def summarize_reviews_by_reviewee(questions, assignment, reviewee_id, summary_ws_url, _session = nil)
self.summary = ({})
self.avg_scores_by_round = ({})
self.avg_scores_by_criterion = ({})
self.summary_ws_url = summary_ws_url
- 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 get_sentences
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_sentences(answer)
sentences = answer.comments.gsub!(/[.?!]/, '\1|').try(:split, '|') || nil unless answer.nil? || answer.comments.nil?
sentences.map!(&:strip) unless sentences.nil?
sentences
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
Missing top-level class documentation comment. Open
class Summary
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Trailing whitespace detected. Open
question_iterator.each do |question|
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Shadowing outer local variable - question
. Open
question_iterator.each do |question|
- Read upRead up
- Exclude checks
This cop looks for use of the same name as outer local variables
for block arguments or block local variables.
This is a mimic of the warning
"shadowing outer local variable - foo" from ruby -cw
.
Example:
# bad
def some_method
foo = 1
2.times do |foo| # shadowing outer `foo`
do_something(foo)
end
end
Example:
# good
def some_method
foo = 1
2.times do |bar|
do_something(bar)
end
end
Use the return of the conditional for variable assignment and comparison. Open
if question[1] == nil
question_iterator = [*question]
else
question_iterator = question[1]
end
- Exclude checks
Prefer the use of the nil?
predicate. Open
if question[1] == nil
- Read upRead up
- Exclude checks
This cop checks for comparison of something with nil using ==.
Example:
# bad
if x == nil
end
# good
if x.nil?
end