mongoclient/mongoclient

View on GitHub
client/imports/modules/ui_components/index.js

Summary

Maintainability
C
1 day
Test Coverage

File index.js has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { ExtendedJSON, SessionManager } from '/client/imports/modules';
import { ReactivityProvider } from '/client/imports/facades';
import $ from 'jquery';
import Helper from '/client/imports/helpers/helper';
import { QueryRender } from '/client/imports/ui/querying';
Severity: Minor
Found in client/imports/modules/ui_components/index.js - About 5 hrs to fix

    Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        init({
          selector, data, empty = true,
          options = { create_option: true, allow_single_deselect: true, persistent_create_option: true, skip_no_results: true },
          sortDataByKey = true,
          prependOptions,
    Severity: Minor
    Found in client/imports/modules/ui_components/index.js - About 1 hr to fix

    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 setAutoCompletionOfCodeMirror has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    const setAutoCompletionOfCodeMirror = function (autoCompleteListMethod) {
      CodeMirror.hint.javascript = (editor) => {
        const cursor = editor.getCursor();
        const currentLine = editor.getLine(cursor.line);
        let start = cursor.ch;
    Severity: Minor
    Found in client/imports/modules/ui_components/index.js - About 1 hr to fix

    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 displayJsonEditorModal has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const displayJsonEditorModal = function (sData) {
      let dataToSet = ExtendedJSON.convertAndCheckJSON(_.unescape(sData));
      dataToSet = dataToSet.ERROR ? _.unescape(sData) : dataToSet;
    
      let modal = $('#json-editor-modal');
    Severity: Minor
    Found in client/imports/modules/ui_components/index.js - About 1 hr to fix

      Function initializeCodeMirror has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          initializeCodeMirror({ divSelector, txtAreaId, keepValue = false, height = 100, noResize = false, extraKeysToAppend = {}, autoCompleteListMethod }) {
            if (!divSelector || !(divSelector instanceof $) || !txtAreaId) return;
            if (autoCompleteListMethod && typeof autoCompleteListMethod !== 'function') return;
            if (extraKeysToAppend && (typeof extraKeysToAppend !== 'object' || extraKeysToAppend.constructor !== Object)) return;
            if (!height || typeof height !== 'number' || !Number.isFinite(height)) return;
      Severity: Minor
      Found in client/imports/modules/ui_components/index.js - About 55 mins to fix

      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 initializeCodeMirrorFirstTime has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      const initializeCodeMirrorFirstTime = function (txtAreaId, extraKeysToAppend, keepValue, height, autoCompleteListMethod, noResize) {
      Severity: Minor
      Found in client/imports/modules/ui_components/index.js - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if (!selectorString || !Array.isArray(columns) || !Array.isArray(columnDefs) || !Array.isArray(data) || !Array.isArray(lengthMenu) || (typeof extraOptions !== 'object')) { return; }
        Severity: Major
        Found in client/imports/modules/ui_components/index.js - About 40 mins to fix

          There are no issues that match your filters.

          Category
          Status