Showing 98 of 1,254 total issues
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
results = @smart_village.query <<~GRAPHQL
query {
publicJsonFile(name: "wasteTypes", version: "1.0.0") {
content
- 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 onChange
has 31 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 onInsert
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
'onInsert': function (evt, node) {
$(node.el).on('click', '.dropdown-menu a', function (evt) {
evt.preventDefault();
evt.stopPropagation();
var img = (evt.target.nodeName.toLowerCase() === 'img') ?
Function initNestedScenes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const initNestedScenes = ($form) => {
const timestamp = Date.now();
$form.find('.nested-tour-stop-scenes').addClass(`nested-tour-stop-scenes-${timestamp}`);
$form
Function initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
formTree.prototype.initialize = function (formDesc) {
formDesc = formDesc || {};
// Keep a pointer to the initial JSONForm
// (note clone returns a shallow copy, only first-level is cloned)
Function validate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
formTree.prototype.validate = function(noErrorDisplay) {
var values = jsonform.getFormValue(this.domRoot);
var errors = false;
Function initLeafletMapTour
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initLeafletMapTour(id) {
let center = CENTER_OF_GERMANY;
let zoom = DEFAULT_ZOOM_LEVEL;
const tourCoordinates = JSON.parse(
Function initClassicEditor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const initClassicEditor = (htmlEditor, rich = false) => {
ClassicEditor.create(
htmlEditor,
!rich && {
toolbar: [
Function updateTabs
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var updateTabs = function (selIdx) {
var tabs = '';
var activateFirstTab = false;
if (selIdx === undefined) {
selIdx = $('> .tabbable > .nav-tabs .active', $nodeid).data('idx');
Function getPreviousNumberOfItems
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
formNode.prototype.getPreviousNumberOfItems = function (values, arrayPath) {
var key = null;
var arrayValue = null;
var childNumbers = null;
var idx = 0;
Function submit
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
formTree.prototype.submit = function(evt) {
var stopEvent = function() {
if (evt) {
evt.preventDefault();
Function resetValues
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
formNode.prototype.resetValues = function () {
var params = null;
var idx = 0;
// Reset value
Function hasRequiredField
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
formTree.prototype.hasRequiredField = function () {
var parseElement = function (element) {
if (!element) return null;
if (element.required && (element.type !== 'boolean')) {
return element;
Consider simplifying this complex logical expression. Open
if (formElement.key) {
// The form element is directly linked to an element in the JSON
// schema. The properties of the form element override those of the
// element in the JSON schema. Properties from the JSON schema complete
// those of the form element otherwise.
Method verify_user
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def verify_user
result = validate_support_id
if result && result.code == "200" && result.body.present?
encounter_server = SmartVillageApi.encounter_server_url
uri = Addressable::URI.parse("#{encounter_server}/v1/support/verify_user.json")
- 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 initLeafletMap
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function initLeafletMap(id) {
const $parentRow = $('#' + id)
.parent()
.parent()
.parent();
- 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
Avoid deeply nested control flow statements. Open
if (_.isString(this.value)) {
if (this.value.indexOf('{{values.') !== -1) {
// This label wants to use the value of another input field.
// Convert that construct into {{jsonform.getValue(key)}} for
// Underscore to call the appropriate function of formData
Avoid deeply nested control flow statements. Open
if tour_stop["payload"]["image"].present? && tour_stop["payload"]["image"]["uri"].present?
image = set_defaults_and_types(tour_stop["payload"]["image"])
image["id"] = "-4"
scene_downloadable_uris.unshift(image)
Avoid deeply nested control flow statements. Open
next if downloadable_uri.blank?
Avoid deeply nested control flow statements. Open
if tour_stop["payload"]["quad"].present?
quad = set_defaults_and_types(tour_stop["payload"]["quad"])
quad["id"] = "-6"
quad["height"] = 1000
quad["width"] = 1000