ikuseiGmbH/smart-village-app-cms

View on GitHub

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
Severity: Minor
Found in app/controllers/waste_calendar_controller.rb - 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 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;
Severity: Minor
Found in lib/jsonform.js - About 1 hr to fix

    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') ?
    Severity: Minor
    Found in lib/jsonform.js - About 1 hr to fix

      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
      Severity: Minor
      Found in app/javascript/partials/_nested_tour_stop_form.js - About 1 hr to fix

        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)
        Severity: Minor
        Found in lib/jsonform.js - About 1 hr to fix

          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;
          
          
          Severity: Minor
          Found in lib/jsonform.js - About 1 hr to fix

            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(
            Severity: Minor
            Found in app/javascript/partials/_leaflet_map.js - About 1 hr to fix

              Function initClassicEditor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const initClassicEditor = (htmlEditor, rich = false) => {
                ClassicEditor.create(
                  htmlEditor,
                  !rich && {
                    toolbar: [
              Severity: Minor
              Found in app/javascript/packs/application.js - About 1 hr to fix

                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');
                Severity: Minor
                Found in lib/jsonform.js - About 1 hr to fix

                  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;
                  Severity: Minor
                  Found in lib/jsonform.js - About 1 hr to fix

                    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();
                    Severity: Minor
                    Found in lib/jsonform.js - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in lib/jsonform.js - About 1 hr to fix

                        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;
                        Severity: Minor
                        Found in lib/jsonform.js - About 1 hr to fix

                          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.
                          Severity: Major
                          Found in lib/jsonform.js - About 1 hr to fix

                            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")
                            Severity: Minor
                            Found in app/controllers/encounters_supports_controller.rb - 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 initLeafletMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function initLeafletMap(id) {
                              const $parentRow = $('#' + id)
                                .parent()
                                .parent()
                                .parent();
                            Severity: Minor
                            Found in app/javascript/partials/_leaflet_map.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

                            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
                            Severity: Major
                            Found in lib/jsonform.js - About 45 mins to fix

                              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)
                              Severity: Major
                              Found in app/controllers/tours_controller.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    next if downloadable_uri.blank?
                                Severity: Major
                                Found in app/controllers/tours_controller.rb - About 45 mins to fix

                                  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
                                  Severity: Major
                                  Found in app/controllers/tours_controller.rb - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language