ikuseiGmbH/smart-village-app-cms

View on GitHub

Showing 1,158 of 1,254 total issues

Complex method DeadlinesController#schedule_push_notifications_queries (37.1)
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)

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  'authfieldset': {
    'template': '<fieldset' +
      '<% if (id) { %> id="<%= id %>"<% } %>' +
      ' class="expandable <%= elt.htmlClass?elt.htmlClass:"" %>">' +
      '<legend>Authentication settings</legend>' +
Severity: Major
Found in lib/jsonform.js and 2 other locations - About 1 hr to fix
lib/jsonform.js on lines 1150..1162
lib/jsonform.js on lines 1163..1175

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  'advancedfieldset': {
    'template': '<fieldset' +
      '<% if (id) { %> id="<%= id %>"<% } %>' +
      ' class="expandable <%= elt.htmlClass?elt.htmlClass:"" %>">' +
      '<legend>Advanced options</legend>' +
Severity: Major
Found in lib/jsonform.js and 2 other locations - About 1 hr to fix
lib/jsonform.js on lines 1150..1162
lib/jsonform.js on lines 1176..1188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  'fieldset': {
    'template': '<fieldset class="form-group jsonform-error-<%= keydash %> <% if (elt.expandable) { %>expandable<% } %> <%= elt.htmlClass?elt.htmlClass:"" %>" ' +
      '<% if (id) { %> id="<%= id %>"<% } %>' +
      '>' +
      '<% if (node.title || node.legend) { %><legend><%= node.title || node.legend %></legend><% } %>' +
Severity: Major
Found in lib/jsonform.js and 2 other locations - About 1 hr to fix
lib/jsonform.js on lines 1163..1175
lib/jsonform.js on lines 1176..1188

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Assignment Branch Condition size for update is too high. [15.26/15]
        Open

          def update
            survey_id = params[:id]
            query = create_params
            begin
              @smart_village.query query

        This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric and https://en.wikipedia.org/wiki/ABC_Software_Metric.

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              var includeFormField = function (formField) {
                return formFieldReferencesKey(formField) ||
                  formField.items && !!_.some(formField.items, function (item) {
                    return includeFormField(item);
                  });
          Severity: Major
          Found in lib/jsonform-split.js and 1 other location - About 1 hr to fix
          lib/jsonform-split.js on lines 171..176

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              var excludeFormField = function (formField) {
                return formFieldReferencesOtherKey(formField) ||
                  formField.items && !!_.some(formField.items, function (item) {
                    return excludeFormField(item);
                  });
          Severity: Major
          Found in lib/jsonform-split.js and 1 other location - About 1 hr to fix
          lib/jsonform-split.js on lines 153..158

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    beforeAddForm: ($container, $form) => {
                      // we only want one initialized texture, so remove eventually created others
                      $form.find('.nested-texture-form').each((index, form) => {
                        if (index > 0) {
                          $(form).remove();
            Severity: Major
            Found in app/javascript/partials/_nested_tour_stop_form.js and 1 other location - About 1 hr to fix
            app/javascript/partials/_nested_content_block_form.js on lines 35..42

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 65.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  beforeAddForm: (_$container, $form) => {
                    // we only want one initialized media content, so remove eventually created others
                    $form.find('.nested-medium-form').each((index, form) => {
                      if (index > 0) {
                        $(form).remove();
            Severity: Major
            Found in app/javascript/partials/_nested_content_block_form.js and 1 other location - About 1 hr to fix
            app/javascript/partials/_nested_tour_stop_form.js on lines 51..58

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 65.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
                  Severity
                  Category
                  Status
                  Source
                  Language