ikuseiGmbH/smart-village-app-cms

View on GitHub

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|
Severity: Major
Found in app/controllers/jobs_controller.rb - About 2 hrs to fix

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

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

        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]}
        Severity: Minor
        Found in app/controllers/constructions_controller.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in app/controllers/defect_reports_controller.rb - About 1 hr to fix

            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")
            Severity: Minor
            Found in app/controllers/tours_controller.rb - About 1 hr to fix

              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?
              
              
              Severity: Minor
              Found in app/controllers/offers_controller.rb - About 1 hr to fix

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

                  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?
                  
                  
                  Severity: Minor
                  Found in app/services/api_request_service.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

                  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 {
                  Severity: Minor
                  Found in app/controllers/dashboard_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

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

                    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
                    Severity: Minor
                    Found in app/controllers/noticeboards_controller.rb - About 1 hr to fix

                      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|
                      Severity: Minor
                      Found in app/controllers/deadlines_controller.rb - About 1 hr to fix

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

                          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] %>" ' +
                              '<% }%>' +
                          Severity: Minor
                          Found in lib/jsonform.js - About 1 hr to fix

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

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

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

                                  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"]
                                  Severity: Minor
                                  Found in app/controllers/surveys_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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language