ikuseiGmbH/smart-village-app-cms

View on GitHub

Showing 1,158 of 1,254 total issues

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

      if (node.options.length > maxColumns) {
        nbRows = Math.ceil(node.options.length / maxColumns);
        data.columns = Math.ceil(node.options.length / nbRows);
      }
      else {
Severity: Major
Found in lib/jsonform.js and 1 other location - About 2 hrs to fix
lib/jsonform.js on lines 738..744

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 92.

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

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

      if (node.options.length > maxColumns) {
        nbRows = Math.ceil(node.options.length / maxColumns);
        data.columns = Math.ceil(node.options.length / nbRows);
      }
      else {
Severity: Major
Found in lib/jsonform.js and 1 other location - About 2 hrs to fix
lib/jsonform.js on lines 670..676

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 92.

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

    def convert_params_for_graphql
      # Convert has_many categories
      if @event_params["categories"].present?
        categories = []
        @event_params["categories"].each do |_key, category|
Severity: Major
Found in app/controllers/events_controller.rb - About 2 hrs to fix

    Assignment Branch Condition size for sign_in is too high. [25.98/15]
    Open

      def sign_in
        auth_server = SmartVillageApi.auth_server_url
        uri = Addressable::URI.parse("#{auth_server}/users/sign_in.json")
        result = ApiRequestService.new(uri.to_s, nil, nil, user_credentials).post_request
        if result.code == "200" && result.body.present?
    Severity: Minor
    Found in app/models/user.rb by rubocop

    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 has too many lines. [20/10]
    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)
    
    

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for schedule_push_notifications_queries is too high. [25.81/15]
    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)
    
    

    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.

    Assignment Branch Condition size for tour_dates is too high. [25.38/15]
    Open

      def tour_dates
        @edit_year = (params[:year].presence || Date.today.year).to_i
        @beginning_of_year = Date.strptime(@edit_year.to_s, "%Y").beginning_of_year
        @end_of_year = Date.strptime(@edit_year.to_s, "%Y").end_of_year
    
    

    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 has too many lines. [20/10]
    Open

      def perform
        @tour_data.each do |tour_data_line|
          @waste_types.each do |waste_type_key, _waste_type|
            next if @tour_assignment[waste_type_key].blank?
            next if @address_assignment[waste_type_key].blank?

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Function onBeforeRender has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        'onBeforeRender': function (data, node) {
          // Before rendering, this function ensures that:
          // 1. direct children have IDs (used to show/hide the tabs contents)
          // 2. the tab to active is flagged accordingly. The active tab is
          // the first one, except if form values are available, in which case
    Severity: Major
    Found in lib/jsonform.js - About 2 hrs to fix

      Method has too many lines. [19/10]
      Open

        def create
          if params[:email].present? && params[:password].present?
            @current_user = User.new(email: params[:email], password: params[:password])
            @current_user.sign_in
            if @current_user.valid?

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [19/10]
      Open

        def index
          results = @smart_village.query <<~GRAPHQL
            query {
              genericItems(genericType: "Job") {
                id
      Severity: Minor
      Found in app/controllers/jobs_controller.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [19/10]
      Open

        def index
          results = @smart_village.query <<~GRAPHQL
            query {
              tours {
                id
      Severity: Minor
      Found in app/controllers/tours_controller.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [19/10]
      Open

        def index
          results = @smart_village.query <<~GRAPHQL
            query {
              pointsOfInterest {
                id

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [19/10]
      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")

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method has too many lines. [19/10]
      Open

        def index
          results = @smart_village.query <<~GRAPHQL
            query {
              genericItems(genericType: "ConstructionSite") {
                id

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for verify_current_user is too high. [24.1/15]
      Open

        def verify_current_user
          return redirect_to log_in_path if session["current_user"].blank?
      
          user_data = {
            email: session["current_user"]["email"],

      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.

      Cyclomatic complexity for convert_params_for_graphql is too high. [15/6]
      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?
      
      

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Function getInitialValue has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var getInitialValue = function (formObject, key, arrayPath, tpldata, usePreviousValues) {
        var value = null;
      
        // Complete template data for template function
        tpldata = tpldata || {};
      Severity: Major
      Found in lib/jsonform.js - About 2 hrs to fix

        Method has too many lines. [18/10]
        Open

          def destroy
            results = @smart_village.query <<~GRAPHQL
              mutation {
                destroyRecord(
                  id: #{params["id"]},
        Severity: Minor
        Found in app/controllers/jobs_controller.rb by rubocop

        This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

        Method has too many lines. [18/10]
        Open

          def destroy
            results = @smart_village.query <<~GRAPHQL
              mutation {
                destroyRecord(
                  id: #{params["id"]},

        This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

        Severity
        Category
        Status
        Source
        Language