Showing 107 of 107 total issues
Method rows
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
def rows
return @rows if @rows
@item_table = [[]]
@rows = [[[]]]
filled_columns = 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
Consider simplifying this complex logical expression. Open
if ((keyCode == 8 &&
(target.tagName != 'INPUT' || (target.type != 'text' && target.type != 'password')) &&
target.tagName != 'TEXTAREA') // Backspace outside input field
|| (event.ctrlKey && keyCode == 65) // a (alles selecteren)
|| (event.ctrlKey && keyCode == 66) // b (favorieten indelen)
Function validatePanel
has 187 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.validatePanel = function(panel) {
if(skipValidations){
return true;
}
var failed = false;
Function onkeydown
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
document.onkeydown = function(event) {
if (event == null){
event = window.event
}
- 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 deserializer.rb
has 404 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Quby
module Questionnaires
module Deserializer
# This symbolizes various things. Do not run on arbitrary JSON.
def self.from_json(json)
Method value_by_regular_values
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def value_by_regular_values
result = {}
if value
result = value.dup
value.each do |key, answer|
- 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
Class Questionnaire
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Questionnaire
extend ActiveModel::Naming
include ActiveModel::Validations
class ValidationError < StandardError; end
File questionnaire.rb
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'active_model'
require 'quby/settings'
require 'quby/questionnaires/entities/flag'
require 'quby/questionnaires/entities/textvar'
require 'quby/questionnaires/entities/validation'
Method validate
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def validate
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
Method build_question
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.build_question(questionnaire, item_json, parent: nil, table: nil)
key = item_json.fetch("key").to_sym
attributes = {
questionnaire: questionnaire,
parent: parent,
Method rows
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
def rows
return @rows if @rows
@item_table = [[]]
@rows = [[[]]]
filled_columns = 0
Class Answer
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Answer
extend ActiveModel::Naming
extend ActiveModel::Translation
# @return [String]
Class AnswersController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class AnswersController < Quby::ApplicationController
DISPLAY_MODES = %w(paged bulk single_page).freeze
before_action :load_token_and_hmac_and_timestamp
before_action :load_return_url_and_token
Class ScoreCalculator
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ScoreCalculator
class UnknownFieldsReferenced < StandardError; end
class MissingAnswerValues < StandardError
attr_reader :questionnaire_key, :values, :missing
File validation.js
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
window.skipValidations = false;
var validationI = 0;
var fail_vals = new Array();
File rest.js
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
function initShowsHides(untilPanelId) {
Quby.panels.find(function (bbPanel) {
bbPanel.initShowsHides(Quby.questions);
return bbPanel.get('panelId') == untilPanelId;
});
Class Question
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Question < Item
MARKDOWN_ATTRIBUTES = %w(description title).freeze
# Standard attributes
attr_accessor :key
Method answer_dsl_module
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def answer_dsl_module # rubocop:disable Metrics/MethodLength
# Have to put this in a local variable so the module definition block can access it
questions_in_var = questions
@answer_dsl_cache ||= Module.new do
File answer.rb
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'active_model'
require 'quby/answers/entities/outcome'
require 'quby/answers/dsl'
module Quby
Method verify_hmac
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def verify_hmac # rubocop:disable CyclomaticComplexity
if Quby::Settings.authorize_with_hmac
fail TokenValidationError, "No HMAC secret is configured" unless Quby::Settings.shared_secret.present?
hmac = (params['hmac'] || @hmac || '').strip
token = (params['token'] || @answer_token || '').strip
- 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"