mconf/mconf-web

View on GitHub

Showing 102 of 130 total issues

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

  def check_statistics_params
    if params[:statistics].present?
      from = params[:statistics][:starts_on_time]
      to = params[:statistics][:ends_on_time]
      date_format = I18n.t('_other.datetimepicker.datepick_rails')
Severity: Minor
Found in app/controllers/manage_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 handle has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def self.handle mailer, message, error, action, args
Severity: Minor
Found in lib/mconf/mailer_error_handler.rb - About 35 mins to fix

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

      def leave
        permission = @space.permissions.find_by_user_id(current_user)
    
        if permission
          permission.destroy
    Severity: Minor
    Found in app/controllers/spaces_controller.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 notify_admins_of_spaces_pending_approval has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.notify_admins_of_spaces_pending_approval
        # The Activities with keys space.created are used to inform the admins that a new space was created.
        activities = get_recent_activity
          .where(trackable_type: 'Space', notified: [nil, false], key: 'space.create')
    
    
    Severity: Minor
    Found in app/workers/space_notifications_worker.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 handle_access_denied has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle_access_denied(exception)
        if ['new', 'create'].include? action_name
          if user_signed_in?
            flash[:error] = t('flash.events.create.permission_error')
            redirect_to events_path
    Severity: Minor
    Found in app/controllers/events_controller.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 user_is_owner_or_belongs_to_rooms_space has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def user_is_owner_or_belongs_to_rooms_space(user, room)
          if (room.owner_type == "User" && room.owner.id == user.id)
            true
          elsif (room.owner_type == "Space")
            space = Space.find_by(id: room.owner.id)
    Severity: Minor
    Found in app/models/abilities/member_ability.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 user_is_owner_or_admin_of_rooms_space has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def user_is_owner_or_admin_of_rooms_space(user, room)
          if (room.owner_type == "User" && room.owner.id == user.id)
            true
          elsif (room.owner_type == "Space")
            space = Space.find_by(id: room.owner.id)
    Severity: Minor
    Found in app/models/abilities/member_ability.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 new_activity_approved has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def new_activity_approved
          if self.new_record?
            # no notifications for new records
            saved_and_not_approved = false
          else
    Severity: Minor
    Found in lib/mconf/approval_module.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 icon_constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def icon_constructor(title=nil, cls=nil, options={})
        options[:class] = options.has_key?(:class) ? cls + " " + options[:class] : cls
        title = title.nil? ? options[:title] : title
        unless title.nil? or title.blank?
          options = options_for_tooltip(title, options)
    Severity: Minor
    Found in app/helpers/icons_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 crop_indexes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.crop_indexes(indexes)
        idx = indexes.clone
        idx = idx.sort_by{ |id| id[0] }
        i = 0
        while i+1 < idx.length
    Severity: Minor
    Found in lib/mconf/highlighter.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 first_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def first_name(min_length = 4)
        unless self.full_name.blank?
          # parse_name(self.full_name)[:first_name]
          names = self.full_name.split(' ')
          names.inject('') do |memo, name|
    Severity: Minor
    Found in app/models/profile.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

    Avoid too many return statements within this method.
    Open

        return fail(:not_found_in_database) if resource.created_by_ldap?
    Severity: Major
    Found in lib/devise/overrides.rb - About 30 mins to fix

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

        def index
          authorize! :index_event, @space
      
          all_events = @space.events(:order => "end_on DESC")
      
      
      Severity: Minor
      Found in app/controllers/space_events_controller.rb - About 25 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 format_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def format_time(date)
          if date.present?
            if date.is_a?(Integer) && date.to_s.length == 13
              value = Time.at(date/1000)
            else
      Severity: Minor
      Found in app/helpers/dates_helper.rb - About 25 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 get_user_locale has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_user_locale(user, use_session=true)
            current_site ||= Site.current
      
            # user locale
            if user_has_locale?(user)
      Severity: Minor
      Found in lib/mconf/locale_controller_module.rb - About 25 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 ldap_filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def ldap_filter(configs)
              base = nil
              unless configs.ldap_filter.blank?
                begin
                  base = Net::LDAP::Filter.construct(configs.ldap_filter)
      Severity: Minor
      Found in lib/devise/strategies/ldap_authenticatable.rb - About 25 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 get_formatted_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_formatted_date(date=nil, with_tz=true)
          if date.nil?
            if with_tz
              I18n::localize(start_on, :format => "%A, %d %b %Y, %H:%M (#{time_zone})")
            else
      Severity: Minor
      Found in app/models/event.rb - About 25 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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          frontpage = Rails.application.config.external_frontpage
      
          if frontpage.blank?
            respond_to do |format|
      Severity: Minor
      Found in app/controllers/frontpage_controller.rb - About 25 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 allowed_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def allowed_params
          is_space_admin = @space.present? && can?(:manage_join_requests, @space)
          if params[:action] == "create"
            if is_space_admin
              [ :role_id, :comment ]
      Severity: Minor
      Found in app/controllers/join_requests_controller.rb - About 25 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 formatted_time_ago has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def formatted_time_ago(date, options = {}, time_ago_options = {})
          base_classes = "thread-updated-at updated-at"
          options[:class] = options.key?(:class) ? "#{base_classes} #{options[:class]}" : base_classes
          options[:title] = I18n.l(date, format: :long)
      
      
      Severity: Minor
      Found in app/helpers/dates_helper.rb - About 25 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