lawrencechanyewlong/wherewolfpro

View on GitHub

Showing 767 of 767 total issues

Method select_contacts has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def select_contacts
    user = User.where(:id => session[:id]).take
    if user
      @receiver_all = []
      @receiver_name_all = []
Severity: Major
Found in app/controllers/event_controller.rb - About 2 hrs to fix

    Method has too many lines. [13/10]
    Open

      def index
        if params[:login]
          @login = true
        end
        if session[:id] 

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Perceived complexity for store_duration is too high. [10/7]
    Open

      def store_duration
        logger.debug params.inspect
        if params[:arrive]
          @duration = 'arrive'
        elsif params[:until_this_time] != '0'
    Severity: Minor
    Found in app/controllers/event_controller.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method has too many lines. [13/10]
    Open

        def parseDuration(d)
          if d
            if d == 'arrive'
              return 'Until I arrive'
            elsif d[d.size-1] == 'm'
    Severity: Minor
    Found in app/controllers/event_controller.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method user_map has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def user_map
        
        def parseDurationToCheckCondition(d)
          # return true if condition is met and stop tracking, else return false if keep tracking
          if d == 'arrive'
    Severity: Minor
    Found in app/controllers/event_controller.rb - About 1 hr to fix

      Method has too many lines. [11/10]
      Open

        def receiver_map
          #@sess = session[:latlong]
          #logger.debug "sess = #{session[:latlong]}"
          id = params[:id]
          if Event.exists?(id: id)
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Perceived complexity for parseDuration is too high. [8/7]
      Open

          def parseDuration(d)
            if d
              if d == 'arrive'
                return 'Until I arrive'
              elsif d[d.size-1] == 'm'
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

      Example:

      def my_method                   # 1
        if cond                       # 1
          case var                    # 2 (0.8 + 4 * 0.2, rounded)
          when 1 then func_one
          when 2 then func_two
          when 3 then func_three
          when 4..10 then func_other
          end
        else                          # 1
          do_something until a && b   # 2
        end                           # ===
      end                             # 7 complexity points

      Perceived complexity for send_mail is too high. [8/7]
      Open

        def send_mail
          gmail = Gmail.new('woofwhere', 'battle431101')
          if session[:id]
            user = User.find_by id: session[:id]
            if user
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

      Example:

      def my_method                   # 1
        if cond                       # 1
          case var                    # 2 (0.8 + 4 * 0.2, rounded)
          when 1 then func_one
          when 2 then func_two
          when 3 then func_three
          when 4..10 then func_other
          end
        else                          # 1
          do_something until a && b   # 2
        end                           # ===
      end                             # 7 complexity points

      Perceived complexity for parseDurationToCheckCondition is too high. [8/7]
      Open

          def parseDurationToCheckCondition(d)
            # return true if condition is met and stop tracking, else return false if keep tracking
            if d == 'arrive'
              # print "\n Inside d=='arrive' \n"
              # print @event.current_lat, @event.current_lng
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

      Example:

      def my_method                   # 1
        if cond                       # 1
          case var                    # 2 (0.8 + 4 * 0.2, rounded)
          when 1 then func_one
          when 2 then func_two
          when 3 then func_three
          when 4..10 then func_other
          end
        else                          # 1
          do_something until a && b   # 2
        end                           # ===
      end                             # 7 complexity points

      Cyclomatic complexity for store_duration is too high. [7/6]
      Open

        def store_duration
          logger.debug params.inspect
          if params[:arrive]
            @duration = 'arrive'
          elsif params[:until_this_time] != '0'
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Block has too many lines. [41/25]
      Open

      ActiveRecord::Schema.define(version: 20160415052728) do
      
        create_table "authorizations", force: :cascade do |t|
          t.string   "provider"
          t.string   "uid"
      Severity: Minor
      Found in db/schema.rb by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

      Assignment Branch Condition size for parseDuration is too high. [15.81/15]
      Open

          def parseDuration(d)
            if d
              if d == 'arrive'
                return 'Until I arrive'
              elsif d[d.size-1] == 'm'
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for store_message is too high. [15.17/15]
      Open

        def store_message
          logger.debug params.inspect
          if params[:message]
            session[:message] = params[:message]
          else
      Severity: Minor
      Found in app/controllers/event_controller.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for login is too high. [15.78/15]
      Open

        def login
          some_user = params['user']
          email = some_user['email']
          password = some_user['password']
          user = User.find_by email:email
      Severity: Minor
      Found in app/controllers/users_controller.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method send_mail has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def send_mail
          gmail = Gmail.new('woofwhere', 'battle431101')
          if session[:id]
            user = User.find_by id: session[:id]
            if user
      Severity: Minor
      Found in app/controllers/event_controller.rb - About 1 hr to fix

        Method toDurationString has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.toDurationString(duration_setting)
                if duration_setting == 'arrive'
                    return "Until I Arrive"
                elsif duration_setting[-4..-1] == 'hour' or duration_setting[-5..-1] == 'hours'
                    if duration_setting[1] == ' '
        Severity: Minor
        Found in app/helpers/welcome_helper.rb - About 1 hr to fix

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

            def user_map
              
              def parseDurationToCheckCondition(d)
                # return true if condition is met and stop tracking, else return false if keep tracking
                if d == 'arrive'
          Severity: Minor
          Found in app/controllers/event_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

          Block has too many lines. [36/25]
          Open

          Rails.application.routes.draw do
            
            get 'welcome/history'
            post 'welcome/history', to:"event#store_event"
            
          Severity: Minor
          Found in config/routes.rb by rubocop

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

            def summary
              
              def parseDuration(d)
                if d
                  if d == 'arrive'
          Severity: Minor
          Found in app/controllers/event_controller.rb - About 1 hr to fix

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

              def store_duration
                logger.debug params.inspect
                if params[:arrive]
                  @duration = 'arrive'
                elsif params[:until_this_time] != '0'
            Severity: Minor
            Found in app/controllers/event_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

            Severity
            Category
            Status
            Source
            Language