fiedl/your_platform

View on GitHub

Showing 213 of 251 total issues

Class User has 74 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ApplicationRecord

  # Virtual attribute, which can be used in member lists to add a note in memory when the user
  # has joined a group or list.
  #
Severity: Major
Found in app/models/user.rb - About 1 day to fix

    Method country_codes_3_letters_from_2_letters has 254 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.country_codes_3_letters_from_2_letters
        {
          "AD" => "AND",
          "AE" => "ARE",
          "AF" => "AFG",
    Severity: Major
    Found in app/models/geo_location.rb - About 1 day to fix

      File schema.rb has 588 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      ActiveRecord::Schema.define(version: 20200917171018) do
      
        create_table "activities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
          t.string   "trackable_type"
          t.integer  "trackable_id"
      Severity: Major
      Found in demo_app/my_platform/db/schema.rb - About 1 day to fix

        Method index has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            authorize! :index, Event
        
            respond_to do |format|
              format.html do
        Severity: Minor
        Found in app/controllers/events_controller.rb - About 1 day 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 initialize has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
            super(page_size: 'A4', top_margin: 0.mm, bottom_margin: 0.mm, left_margin: 0.mm, right_margin: 0.mm)
            
            @document_title = options[:title]
            @document_updated_at = options[:updated_at]
        Severity: Minor
        Found in app/pdfs/address_labels_dpag7037_pdf.rb - About 7 hrs 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 44 (exceeds 5 allowed). Consider refactoring.
        Open

          def <<(object)
            begin
              if object.kind_of? User
                raise RuntimeError 'Users can only be assigned to groups.' unless self.kind_of? Group
                self.assign_user(object) unless self.child_users.include? object
        Severity: Minor
        Found in app/models/concerns/structureable.rb - About 6 hrs 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

        File ability.rb has 401 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class Ability
          include CanCan::Ability
        
          def ability_classes
            [
        Severity: Minor
        Found in app/models/ability.rb - About 5 hrs to fix

          Method initialize has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(user, options = {})
              # Define abilities for the passed in user here. For example:
              #
              #   user ||= User.new # guest user (not logged in)
              #   if user.admin?
          Severity: Minor
          Found in app/models/ability.rb - About 5 hrs 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

          File user.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class User < ApplicationRecord
          
            # Virtual attribute, which can be used in member lists to add a note in memory when the user
            # has joined a group or list.
            #
          Severity: Minor
          Found in app/models/user.rb - About 5 hrs to fix

            Method user_params has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

              def user_params
                permitted_keys = []
                if @user
                  permitted_keys += [:avatar, :remove_avatar, :avatar_background] if can? :update, @user
                  unless params[:user].try(:[], :avatar).present?
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 5 hrs 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

            File icon_helper.rb has 378 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module IconHelper
            
              def icon(icon_key)
                if icon_key.to_s.in? ['beer', 'coffee', 'key', 'lock', 'unlock', 'unlock-alt', 'archive', 'undo', 'history', 'folder-open', 'sort-alpha-asc', 'sort-numeric-asc', 'sort-numeric-desc']
                  awesome_icon(icon_key)
            Severity: Minor
            Found in app/helpers/icon_helper.rb - About 5 hrs to fix

              Method search has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def search(query, limit: 10000, current_user: nil)
                    if current_user
                      result = search_in_my_groups(query, user: current_user)
                      result = search_in_my_corporations(query, user: current_user) unless result.present?
                    end
              Severity: Minor
              Found in app/models/concerns/group_search.rb - About 4 hrs 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 store_as_posts_when_authorized has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

                def store_as_posts_when_authorized
                  recipient_emails.collect do |recipient_email|
                    if group = ProfileFields::MailingListEmail.where(value: recipient_email).first.try(:profileable)
                      if no_duplicates_exist?(group) || Rails.env.development?
                        ability = Ability.new(self.sender_user)
              Severity: Minor
              Found in app/models/received_post_mail.rb - About 4 hrs 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

              Class Page has 36 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Page < ApplicationRecord
              
                has_dag_links ancestor_class_names: %w(Page User Group Event), descendant_class_names: %w(Page User Group Event Post), link_class_name: 'DagLink'
                #after_save { parent.try(:touch) }  # This causes some specs to fail. TODO: Check if this is a spec issue or has destructive implications.
              
              
              Severity: Minor
              Found in app/models/page.rb - About 4 hrs to fix

                Class Address has 35 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Address < ProfileField
                    def self.model_name; ProfileField.model_name; end
                
                    def as_json(*args)
                      super.merge({
                Severity: Minor
                Found in app/models/profile_fields/address.rb - About 4 hrs to fix

                  Method initialize has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
                      super(page_size: 'A4', top_margin: 8.mm, bottom_margin: 8.mm, left_margin: 10.mm, right_margin: 10.mm)
                  
                      @document_title = options[:title]
                      @document_updated_at = options[:updated_at]
                  Severity: Minor
                  Found in app/pdfs/address_labels_zweckform3475_pdf.rb - About 4 hrs 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

                  Class Event has 34 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Event < ApplicationRecord
                  
                    validates :start_at, presence: true
                    before_validation -> { self.start_at ||= self.created_at || Time.zone.now }
                  
                  
                  Severity: Minor
                  Found in app/models/event.rb - About 4 hrs to fix

                    Method processed_data has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def processed_data
                        if preset.to_s.in?(['birthday_list', 'address_list', 'dpag_internetmarke', 'phone_list']) && @data.kind_of?(Group)
                          # To be able to generate lists from Groups as well as search results, these presets expect
                          # an Array of Users as data. If a Group is given instead, just take the group members as data.
                          #
                    Severity: Minor
                    Found in app/models/list_export.rb - About 3 hrs 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

                    File geo_location.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class GeoLocation < ApplicationRecord
                    
                      # When to perform geocoding queries (to google)
                      # ==========================================================================================
                    
                    
                    Severity: Minor
                    Found in app/models/geo_location.rb - About 3 hrs to fix

                      Class Role has 31 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Role
                      
                        def initialize(given_user, given_object)
                          @user = given_user
                          @object = given_object
                      Severity: Minor
                      Found in app/models/role.rb - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language