fiedl/your_platform

View on GitHub

Showing 251 of 251 total issues

Method execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute( params )
      raise RuntimeError, 'no user_id given' unless params[ :user_id ]
      raise RuntimeError, 'no group_id given' unless params[ :group_id ]

      user = User.find( params[ :user_id ] )
Severity: Minor
Found in app/models/workflow_kit/remove_from_group_brick.rb - About 45 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

Method restore_profile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def restore_profile
    raise "This user (#{id}) already has an existing profile. Not restoring from backup file." if profile_fields.any?
    hash = ActiveSupport::JSON.decode(File.read(latest_backup_file))

    if (address = hash['profile_fields'].select { |pf| pf['type'] == "ProfileFields::Address" }.first) && address['children'].present?
Severity: Minor
Found in app/models/concerns/user_backup.rb - About 45 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

                 book_rate_line(address_label) if @book_rate and address_label
Severity: Major
Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                     rescue Prawn::Errors::IncompatibleStringEncoding
                       logger.warn "PDF ADDRESS LABEL EXPORT ENCODING ISSUE for #{address_label.name}."
                       text "ENCODING ISSUE!"
    Severity: Major
    Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    part.body.raw_source.replace part.body.decoded.gsub(search, replace) if part.body.decoded.include? search
      Severity: Major
      Found in core_ext/mail/message.rb - About 45 mins to fix

        Method fill_small_map_address_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def fill_small_map_address_fields
            # On collection groups, e.g. the corporations_parent group, only the
            # groups should be shown on the map. These groups have a lot of
            # child groups with address profile fields.
            #
        Severity: Minor
        Found in app/controllers/groups_controller.rb - About 45 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

        Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            authorize! :update, room
        
            terminate_existing_occupancies
        
        
        Severity: Minor
        Found in app/controllers/api/v1/room_occupancies_controller.rb - About 45 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

                         sender_line if @sender and address.to_s.present?
        Severity: Major
        Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                           address.gsub!("\nDeutschland", "") if I18n.locale == :de # in order to save space for in-country deliveries.
          Severity: Major
          Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 45 mins to fix

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

                  if str.present?
                    return 12.pt if num_of_lines_required(str, 12.pt) < 5
                    return 10.pt if num_of_lines_required(str, 10.pt) < 6
                    return 8.pt if num_of_lines_required(str, 8.pt) < 8
                  end
            Severity: Minor
            Found in app/pdfs/address_labels_pdf.rb and 1 other location - About 40 mins to fix
            app/pdfs/address_labels_pdf.rb on lines 29..34

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

            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

                  if str.present?
                    return 10.pt if num_of_lines_required(str, 12.pt) < 5
                    return 8.pt if num_of_lines_required(str, 10.pt) < 6
                    return 6.pt if num_of_lines_required(str, 8.pt) < 8
                  end
            Severity: Minor
            Found in app/pdfs/address_labels_pdf.rb and 1 other location - About 40 mins to fix
            app/pdfs/address_labels_pdf.rb on lines 36..41

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

            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

            Consider simplifying this complex logical expression.
            Open

                if self.value_changed? && (! @do_not_save_parent) && self.parent && self.parent.reload && self.parent.children.reload && (self.parent.value != (composed_value = self.parent.composed_value))
                  self.parent.update_attributes value: composed_value
                  @do_not_save_parent = false
                end
            Severity: Major
            Found in app/models/concerns/profile_field_composed_value.rb - About 40 mins to fix

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def initialize(name, address_field, name_surrounding_field, personal_title = '', company = '')
              Severity: Minor
              Found in app/models/address_label.rb - About 35 mins to fix

                Method support_request_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def support_request_email(sender_user, receiver_email, text, meta_data, navable)
                Severity: Minor
                Found in app/mailers/support_request_mailer.rb - About 35 mins to fix

                  Method identify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.identify(login_string)
                  
                      # Priorization: Check alias first. (Bug fix)
                      user_identified_by_alias = User.find_by_alias(login_string)
                      users_that_match_the_login_string = [ User.find_by_alias(login_string) ] if user_identified_by_alias
                  Severity: Minor
                  Found in app/models/user_account.rb - About 35 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

                  Method << has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def <<(child)
                      unless child.in? self.children
                        if child.in? self.descendants
                          link = DagLink.where(
                            ancestor_type: 'Page', ancestor_id: self.id,
                  Severity: Minor
                  Found in app/models/page.rb - About 35 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

                  Method geo_information has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def geo_information( key )
                          return nil if self.value == "—"
                          return geo_location.send(key).strip if self.value.present? && geo_location.send(key).kind_of?(String) && geo_location.send(key).strip.present?
                          return geo_location.send(key) if self.value.present? && geo_location.send(key).present?
                        end
                  Severity: Minor
                  Found in app/models/profile_fields/address.rb - About 35 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

                  Method access_indicator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def access_indicator
                      if current_navable.respond_to?(:draft?) && current_navable.draft?
                        content_tag :span, t(:draft), class: 'label label-primary draft_label'
                      elsif current_access
                        css = 'access-indicator has_tooltip'
                  Severity: Minor
                  Found in app/helpers/access_indicator_helper.rb - About 35 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

                  Method generate_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.generate_for(user)
                      raise RuntimeError, 'no user given' if not user
                      raise RuntimeError, 'the given user has no last_name' if not user.last_name.present?
                      raise RuntimeError, 'the given user has no first_name' if not user.first_name.present?
                  
                  
                  Severity: Minor
                  Found in app/models/user_alias.rb - About 35 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

                  Method needs_review= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def needs_review=(new_needs_review)
                      new_needs_review = false if new_needs_review == "false"
                      if new_needs_review != self.needs_review
                        attribute_will_change!(:needs_review)
                      end
                  Severity: Minor
                  Found in app/models/concerns/review.rb - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language