hacken-in/hacken-in

View on GitHub

Showing 16 of 144 total issues

Method reset_pk_sequence! has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

                def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
                    unless pk and sequence
                        default_pk, default_sequence = pk_and_sequence_for(table)

                        pk ||= default_pk
Severity: Minor
Found in config/initializers/backport_pg_10_support_to_rails_4.rb - About 2 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 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Event < ActiveRecord::Base
  include TwitterHashTagFixer

  validates_presence_of :name
  validates_presence_of :category
Severity: Minor
Found in app/models/event.rb - About 2 hrs to fix

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

    class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :token_authenticatable, :confirmable, :lockable and :timeoutable
      devise :database_authenticatable, :registerable, :omniauthable,
             :recoverable, :rememberable, :trackable, :validatable
    Severity: Minor
    Found in app/models/user.rb - About 2 hrs to fix

      Method update_with_password_pass has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_with_password_pass(params={})
      
          if params[:password].blank? and params[:email] == self.email
            params.delete(:current_password)
            params.delete(:password)
      Severity: Minor
      Found in app/models/user.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 <=> has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def <=>(other)
          if (self.occurrence.year != other.occurrence.year) || (self.occurrence.month != other.occurrence.month) || (self.occurrence.day != other.occurrence.day)
            # not on same day
            return self.occurrence <=> other.occurrence
          elsif self.full_day
      Severity: Minor
      Found in app/models/single_event.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(user)
          if user.present? && user.admin?
            can :manage, :all
          elsif user.present?
            # Achtung! Keine Blocks benutzen, sondern immer die
      Severity: Minor
      Found in app/models/active_admin_ability.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 initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(user)
          if user.present? && user.admin?
            can :manage, :all
          elsif user.present?
            # Achtung! Keine Blocks benutzen, sondern immer die
      Severity: Minor
      Found in app/models/active_admin_ability.rb - About 1 hr to fix

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

          def is_for_user?(user)
            return true unless user
            # Let us be a little more verbose than the old code
            # !((self.event.tag_list & user.hate_list).length > 0 && self.users.exclude?(user))
            hated_tags_event = (self.event.tag_list & user.hate_list)
        Severity: Minor
        Found in app/models/single_event.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 all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def all
        
            # If there is no token, but we are currently logged in
            if current_user
              @auth = Authorization.create_authorization(request.env["omniauth.auth"], current_user)
        Severity: Minor
        Found in app/controllers/callbacks_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 fix_twitter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def fix_twitter
            if twitter 
              if twitter[0] == '@'
                self.twitter = twitter[1..-1]
              elsif m = twitter.match(/http(?:s)?:\/\/twitter.com\/(.*)/)
        Severity: Minor
        Found in lib/twitter_hash_tag_fixer.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 self.full_name.downcase <=> other.full_name.downcase
        Severity: Major
        Found in app/models/single_event.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return time_comparison
          Severity: Major
          Found in app/models/single_event.rb - About 30 mins to fix

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

              def css_class
                [
                  (active ? "active" : false),
                  (has_events ? "has_events" : false),
                  (date == Date.today ? "today" : false)
            Severity: Minor
            Found in app/presenters/day_presenter.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def update
                  params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
                  params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
                  reconstruct_start_time
                  update! do |success|
            Severity: Minor
            Found in app/admin/events.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def create
                  params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
                  params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
                  reconstruct_start_time
                  create! do |success|
            Severity: Minor
            Found in app/admin/events.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 add_missing_to_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def add_missing_to_list(handles, list)
                handles_in_list = members(list).map(&:screen_name)
                (handles - handles_in_list).each do |screen_name|
                  begin
                    request_wrapper do
            Severity: Minor
            Found in lib/twitter_list_updater.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