dannyighsu/ucb-senior-map

View on GitHub

Showing 9 of 9 total issues

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

  def create
    super do
      user = params[:user]
      if user[:first_name] == "" or user[:last_name] == ""
        flash[:notice] = "Please enter your name."
Severity: Major
Found in app/controllers/users_controller.rb - About 2 hrs to fix

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

      def create
        super do
          user = params[:user]
          if user[:first_name] == "" or user[:last_name] == ""
            flash[:notice] = "Please enter your name."
    Severity: Minor
    Found in app/controllers/users_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 linkedin has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def linkedin
        url = HTTParty.post("https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=#{params[:code]}&redirect_uri=#{request.base_url+linkedin_path}&client_id=#{ENV["LinkedIn_ID"]}&client_secret=#{ENV["LinkedIn_Secret"]}", :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' })
        logger.info(url)
        response = HTTParty.get("https://api.linkedin.com/v1/people/~:(location,summary,positions,first-name,last-name)?format=json", :headers => { "Host" => "api.linkedin.com", "Connection" => "Keep-Alive", "Authorization" => "Bearer #{url["access_token"]}"})
        logger.info(response)
    Severity: Minor
    Found in app/controllers/linkedin_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 linkedin has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def linkedin
        url = HTTParty.post("https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=#{params[:code]}&redirect_uri=#{request.base_url+linkedin_path}&client_id=#{ENV["LinkedIn_ID"]}&client_secret=#{ENV["LinkedIn_Secret"]}", :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' })
        logger.info(url)
        response = HTTParty.get("https://api.linkedin.com/v1/people/~:(location,summary,positions,first-name,last-name)?format=json", :headers => { "Host" => "api.linkedin.com", "Connection" => "Keep-Alive", "Authorization" => "Bearer #{url["access_token"]}"})
        logger.info(response)
    Severity: Minor
    Found in app/controllers/linkedin_controller.rb - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

              return
      Severity: Major
      Found in app/controllers/users_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return
        Severity: Major
        Found in app/controllers/users_controller.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return
          Severity: Major
          Found in app/controllers/users_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return
            Severity: Major
            Found in app/controllers/users_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return
              Severity: Major
              Found in app/controllers/users_controller.rb - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language