fiedl/your_platform

View on GitHub

Showing 213 of 251 total issues

Method from_omniauth has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def from_omniauth(auth)
      case auth.provider
      when 'github', 'twitter', 'google_oauth2', 'facebook'
        User.find_by_email auth.info.email if auth.info.email.present?
      else
Severity: Minor
Found in app/models/concerns/user_omniauth.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 scan_address_field has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.scan_address_field(address_field)
    address_field.issues.destroy_auto
    if address_field.postal_or_first_address?
      if address_field.value.to_s.split("\n").count < 2
        address_field.issues.create title: 'issues.address_has_too_few_lines', description: 'issues.address_needs_between_2_and_4_lines', responsible_admin_id: address_field.profileable.try(:responsible_admin_id)
Severity: Minor
Found in app/models/issue.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 create_special_group has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def create_special_group( group_flag, options = {} )
      if find_special_group( group_flag, options )
        raise ActiveRecord::RecordNotSaved, "special group :#{group_flag} already exists."
      end
      object_to_create = options[:parent_element].try(:child_groups)
Severity: Minor
Found in app/models/concerns/special_groups.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 handle_inline_attachment_uploads has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_inline_attachment_uploads
    if params[:inline_attachment].to_b == true
      params[:attachment] ||= {}
      params[:attachment][:parent_type] ||= params[:parent_type] if params[:parent_type].present?
      params[:attachment][:parent_id] ||= params[:parent_id] if params[:parent_id].present?
Severity: Minor
Found in app/controllers/attachments_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 find_object has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def find_object
    @object = base.descendant_groups.find_by token: query if base.respond_to? :descendant_groups
    @object ||= NavNode.where('url_component like ?', like_query).limit(1).first.try(:navable) if not params[:search_base].present?  # for example "erlangen/" -- as entry point for navigation
    @object ||= base.descendant_groups.where('name like ?', like_query).limit(1).first if base.respond_to? :descendant_groups
    @object ||= base.descendant_pages.where('title like ?', like_query).limit(1).first if base.respond_to? :descendant_pages
Severity: Minor
Found in app/controllers/compact_nav_search_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 text has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def text
    if self.multipart?
      self.parts.each do |part|
        if part.text?
          return part.body.decoded
Severity: Minor
Found in core_ext/mail/message.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 events has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def events
    if group
      @events = group.events_with_subgroups.where(publish_on_local_website: true)
    else
      @events = Event.where(publish_on_global_website: true)
Severity: Minor
Found in app/controllers/api/v1/public/events_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 list_export_by_preset has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def list_export_by_preset(preset, options = {})
    case preset.to_s
    when 'name_list', '', nil
      self.export_name_list(options)
    when 'address_list'
Severity: Minor
Found in app/models/concerns/group_list_exports.rb - About 1 hr to fix

    Method restore_profile has 30 lines of code (exceeds 25 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 1 hr to fix

      Method show has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show
          authorize! :read, group
          authorize! :export_member_list, group
      
          list_preset_i18n = I18n.translate(list_preset) if list_preset.present?
      Severity: Minor
      Found in app/controllers/list_exports_controller.rb - About 1 hr to fix

        Method show has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            set_current_title group.title
            set_current_navable group
            set_current_tab :contacts
        
        
        Severity: Minor
        Found in app/controllers/groups_controller.rb - About 1 hr to fix

          Method generate_dummy_user has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def generate_dummy_user
              Faker::Config.locale = Setting.preferred_locale || 'de'
          
              user = User.new
              user.first_name = Faker::Name.first_name
          Severity: Minor
          Found in app/models/concerns/group_dummy_users.rb - About 1 hr to fix

            Method generate_public_website has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def generate_public_website
                homepage = child_pages.where(type: "Pages::PublicPage").first
                if not homepage
                  if self.subdomain.present?
                    domain = "#{self.subdomain}.#{AppVersion.domain}"
            Severity: Minor
            Found in app/models/concerns/group_public_website.rb - About 1 hr to fix

              Method initialize has 28 lines of code (exceeds 25 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 1 hr to fix

                Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def create
                    raise ActionController::ParameterMissing, 'name not given' if params[:first_name].blank? or params[:last_name].blank?
                    raise ActionController::ParameterMissing, 'email not given' if params[:email].blank?
                    raise ActionController::ParameterMissing, 'no password' if params[:password].blank?
                    raise ActionController::BadRequest, 'password too short' if params[:password].length < 9
                Severity: Minor
                Found in app/controllers/setup_controller.rb - About 1 hr to fix

                  Method parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.parse(payload, sso_secret = nil)
                      sso = new
                      sso.sso_secret = sso_secret if sso_secret
                      parsed = Rack::Utils.parse_query(payload)
                      if sso.sign(parsed["sso"]) != parsed["sig"]
                  Severity: Minor
                  Found in app/services/single_sign_on.rb - About 1 hr to fix

                    Method events has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def events
                        if show_events?
                          events = show_events_for_group.try(:events) || Event.all
                          events = events.where(publish_on_global_website: true) if settings.show_only_events_published_on_global_website
                          events = events.where(publish_on_local_website: true) if settings.show_only_events_published_on_local_website
                    Severity: Minor
                    Found in app/models/concerns/page_events.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def parse(datetime, type)
                          return unless datetime
                          return datetime if datetime.respond_to?(:strftime) # already a Date/Time object -> no need to parse it
                    
                          translate_month_and_day_names(datetime)
                    Severity: Minor
                    Found in app/models/localized_date_time_parser.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 fill_cache has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def fill_cache
                        super
                        parent.fill_cache if parent && parent.children.first.id == self.id
                        if !parent && profileable && profileable.respond_to?(:renew_cache)
                          self.class.cached_profileable_methods_depending_on_profile_fields.each do |method|
                    Severity: Minor
                    Found in app/models/concerns/profile_field_caching.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 confirm_admins_only_access_if_needed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def confirm_admins_only_access_if_needed
                        if request.get? and request.format.html?
                          if current_navable and can?(:read, current_navable) and not current_ability_as_user.can?(:read, current_navable)
                            confirm_admins_only_access
                          end
                    Severity: Minor
                    Found in app/controllers/concerns/confirm_admins_only_access.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