Showing 107 of 107 total issues
Method value_by_values
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def value_by_values
result = {}
if value
result = value.dup
value.each_key do |key|
- 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 from_json
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_json(json)
# TODO: last_update
Entities::Questionnaire.new(json.fetch("key"), json).tap do |questionnaire|
questionnaire.title = json.fetch("title")
questionnaire.description = json.fetch("description")
Method build_question_validation
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.build_question_validation(attrs)
base_validation = {
type: attrs.fetch("type").to_sym,
explanation: attrs["explanation"] # not always specified for min/max validation
}
Function handleUpHotKeys
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleUpHotKeys(event){
event.which = event.which || event.keyCode;
if ($(lastInput).is("input[type=submit]") && (event.which == 32 || event.which == 13)){
event.target.click();
return;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($(inputs[0]).attr('class') === 'date') {
try {
if(allDateFieldsFilledIn(inputs)) {
var enteredDate = parsePartialDate(inputs);
var maximumDate = new Date(validation.value)
- 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 77.
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
if ($(inputs[0]).attr('class') === 'date') {
try {
if(allDateFieldsFilledIn(inputs)) {
var enteredDate = parsePartialDate(inputs);
var minimumDate = new Date(validation.value);
- 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 77.
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
Function assignValue
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function assignValue(qkey, val){
var inputs;
if(val instanceof Object){//checkbox vals are passed as an object hash
inputs = $("[name^='answer["+qkey+"_'][type!='hidden']");
} else {
- 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
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate
questionnaire.questions.each do |question|
next unless question
next if question.hidden?
Method build_chart
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.build_chart(questionnaire, chart_json)
base_args = {
title: chart_json.fetch("title"),
plottables: chart_json.fetch("plottables").map do |plottable_json|
Quby::Questionnaires::Entities::Charting::Plottable.new(
Method calculate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def calculate # rubocop:disable Metrics/MethodLength
results = {}
score_results = {}
action_results = {}
completion_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
Method initialize
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(key, options = {})
super(options)
@extra_data ||= {}
@options = []
Function handleDownHotKeys
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleDownHotKeys(event){
event.which = event.charCode || event.which || event.keyCode;
if ($(lastInput).is("textarea") || $(lastInput).is("input[type=submit]") && (event.which == 32 || event.which == 13)) {
return;
}
Function setAllCheckboxes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function setAllCheckboxes(checked, allKey, nothingKey, question, checkValue){
if(checked){
// Setting all other checkboxes to checkValue
check_boxes = $("#answer_"+question+"_input").find("input[type=checkbox]:not(:disabled)");
if(check_boxes.length == 0){
- 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 update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update
if session[:has_downloaded_pdf_for] == @answer.id && defined?(Appsignal) && on_ios_safari?
Appsignal.increment_counter("ios_safari_downloaded_pdf_and_pressed_done", 1)
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 to_codebook
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def to_codebook(questionnaire, opts)
return nil if inner_title
output = []
if question.type == :check_box
- 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 cleanup_input
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def cleanup_input
questionnaire.questions.each do |question|
next unless question
next if question.hidden?
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
if(allDateFieldsFilledIn(inputs)) {
var enteredDate = parsePartialDate(inputs);
var maximumDate = new Date(validation.value)
if(enteredDate > maximumDate) {
- 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 63.
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
Function handleAjaxFormRequests
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleAjaxFormRequests(prepareDisplayModeCallback) {
$(document).on('ajax:success', "form", function(event, data, status, xhr) {
content_type = (xhr.getResponseHeader("content-type")||"").split(';')[0];
if (content_type == 'text/html') { // not json response
$('#content').replaceWith(data);
Similar blocks of code found in 2 locations. Consider refactoring. Open
case "answer_group_maximum":
var count = calculateAnswerGroup(validation.group, panel);
if(count.visible > 0 && count.answered > validation.value){
pushFailVal(validation.type);
}
- 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 63.
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
case "answer_group_minimum":
var count = calculateAnswerGroup(validation.group, panel);
if(count.visible > 0 && count.answered < validation.value){
pushFailVal(validation.type);
}
- 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 63.
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