Showing 98 of 1,254 total issues
Method convert_params_for_graphql
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_params_for_graphql
# Convert has_many contacts
if @job_params["contacts"].present?
contacts = []
@job_params["contacts"].each do |_key, contact|
Function recSetObjKey
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
var recSetObjKey = function (obj, keyparts, value) {
var arrayMatch = null;
var reArray = /\[([0-9]*)\]$/;
var subkey = keyparts.shift();
var idx = 0;
Function extractDefaultValues
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
var extractDefaultValues = function (schemaItem, path) {
var properties = null;
var child = null;
if (!schemaItem || (schemaItem !== Object(schemaItem))) return null;
Method edit
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def edit
results = @smart_village.query <<~GRAPHQL
query {
genericItem(
id: #{params[:id]}
Method index
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
results = @smart_village.query <<~GRAPHQL
query {
genericItems(genericType: "DefectReport") {
id
Method set_defaults_and_types
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_defaults_and_types(entry)
# set default values
entry["color"] = entry["color"].presence || "#ffffff" if entry.keys.include?("color")
if entry.keys.include?("temperature")
Method convert_params_for_graphql
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_params_for_graphql
# Convert has_many content_blocks(which has_many media_contents)
content_block_params = @offer_params["content_blocks"]
return unless content_block_params.present?
Method create
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
results = @smart_village.query <<~GRAPHQL
query {
publicJsonFile(name: "wasteTypes", version: "1.0.0") {
content
Method get_request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_request(content_type_xml = false, pem = nil)
uri = Addressable::URI.parse(@uri.strip).normalize
uri.query = [uri.query, URI.encode_www_form(@params)].join("&") if @params&.any?
- 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 index
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def index
if helpers.visible_in_role?("role_news_item")
news_results = @smart_village.query <<~GRAPHQL
query {
newsItems {
- 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 schedule_push_notifications_queries
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def schedule_push_notifications_queries(id = nil)
if @push_notifications.present?
@push_notifications.each do |_key, push_notification|
next unless nested_values?(push_notification.except(:recurring).to_h).include?(true)
- 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
Function onInsert
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
'onInsert': function (evt, node) {
var activeClass = 'active';
var elt = node.formElement || {};
if (elt.activeClass) {
activeClass += ' ' + elt.activeClass;
Method index
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
results = @smart_village.query <<~GRAPHQL
query {
genericItems(genericType: "Noticeboard") {
id
Method convert_params_for_graphql
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_params_for_graphql
# Convert has_many categories
if @deadline_params["categories"].present?
categories = []
@deadline_params["categories"].each do |_key, category|
Function onInsert
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
'onInsert': function (evt, node) {
var setup = function () {
var formElement = node.formElement || {};
var ace = window.ace;
var editor = ace.edit($(node.el).find('#' + escapeSelector(node.id) + '__ace').get(0));
Function fieldTemplate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
jsonform.fieldTemplate = function(inner) {
return '<div ' +
'<% for(var key in elt.htmlMetaData) {%>' +
'<%= key %>="<%= elt.htmlMetaData[key] %>" ' +
'<% }%>' +
Function getObjKey
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
jsonform.util.getObjKey = function (obj, key, ignoreArrays) {
var innerobj = obj;
var keyparts = key.split(".");
var subkey = null;
var arrayMatch = null;
Function onChange
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
'onChange': function (evt, elt) {
// The "transloadit" function should be called only once to enable
// the service when the form is submitted. Has it already been done?
if (elt.ownerTree._transloadit_bound) {
return false;
Function convertFormField
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
var convertFormField = function (formField, splitPart, parentField) {
var convertedField = null;
var keepField = formField.root ||
(splitPart === 'all') ||
Method convert_params_for_graphql
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def convert_params_for_graphql
# Convert date, as we always have and need exactly one
if @survey_params["dates"].present?
dates = @survey_params.delete(:dates)
@survey_params["date"] = dates["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"