jnaqsh/nerdnews

View on GitHub

Showing 17 of 21 total issues

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

  def create
    session[:authhash] = nil #ensure no one sets it
    omniauth = request.env['omniauth.auth']
    provider = request.env['omniauth.auth']['provider']
    @authhash = Hash.new
Severity: Minor
Found in app/controllers/identities_controller.rb - About 5 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

Method determine_browser_and_os has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def determine_browser_and_os(ua = request.env["HTTP_USER_AGENT"])
    ua = (ua||"").downcase
    br = case ua
      when /opera[\/,\s+](\d+)/
        o = %W(opera opera#{$1})
Severity: Minor
Found in app/helpers/application_helper.rb - About 3 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

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

  def create
    @story = Story.find(params[:story_id])
    @comment = @story.comments.build(comment_params)
    @comment.user = nil
    @comment.parent_id = comment_params[:parent_id].empty? ? nil : Comment.find(comment_params[:parent_id])
Severity: Minor
Found in app/controllers/comments_controller.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

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

  def create
    session[:authhash] = nil #ensure no one sets it
    omniauth = request.env['omniauth.auth']
    provider = request.env['omniauth.auth']['provider']
    @authhash = Hash.new
Severity: Minor
Found in app/controllers/identities_controller.rb - About 1 hr to fix

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

      def create
        if params[:cancel]
          delete_sessions
          redirect_to root_url, flash: { error: t('controllers.users.create.flash.canceled') }
        else
    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

    Function drawBubble has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var drawBubble = function(context, label, colour) {
    
            // automatic abbreviation for long (>2 digits) numbers
            if (typeof label == 'number' && label > 99 && options.abbreviate) {
                label = abbreviateNumber(label);
    Severity: Minor
    Found in app/assets/javascripts/tinycon.js - About 1 hr to fix

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

        def determine_browser_and_os(ua = request.env["HTTP_USER_AGENT"])
          ua = (ua||"").downcase
          br = case ua
            when /opera[\/,\s+](\d+)/
              o = %W(opera opera#{$1})
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 1 hr to fix

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

          def create
            @story = Story.find(params[:story_id])
            @comment = @story.comments.build(comment_params)
            @comment.user = nil
            @comment.parent_id = comment_params[:parent_id].empty? ? nil : Comment.find(comment_params[:parent_id])
        Severity: Minor
        Found in app/controllers/comments_controller.rb - About 1 hr to fix

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

            def create
              if params[:cancel]
                delete_sessions
                redirect_to root_url, flash: { error: t('controllers.users.create.flash.canceled') }
              else
          Severity: Minor
          Found in app/controllers/users_controller.rb - About 1 hr to fix

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

              def create
                begin
                  @rating         = Rating.find(votes_params[:rating_id])
                  @user           = current_user
                  @vote           = Vote.new()
            Severity: Minor
            Found in app/controllers/votes_controller.rb - About 1 hr to fix

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

                def publish
                  respond_to do |format|
                    if @story.mark_as_published(current_user, story_url(@story))
              
                      rate_user(@story.user, 3) if @story.user #rate for user who wrote a story
              Severity: Minor
              Found in app/controllers/stories_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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  @story.attributes = story_params
              
                  respond_to do |format|
                    if params[:preview_button]
              Severity: Minor
              Found in app/controllers/stories_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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  if current_user
                    @user = current_user
                    @story = @user.stories.build(story_params)
                  else
              Severity: Minor
              Found in app/controllers/stories_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 new has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def new
                  if pre_auth.authorizable?
                    if Doorkeeper::AccessToken.matching_token_for(pre_auth.client, current_resource_owner.id, pre_auth.scopes) || skip_authorization?
                      auth = authorization.authorize
                      redirect_to auth.redirect_uri
              Severity: Minor
              Found in app/controllers/oauth/authorizations_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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def show
                  @story = Story.includes([:tags, :user, :publisher, {:votes => [:rating, :user]}]).find(params[:id])
              
                  share_by_mail
              
              
              Severity: Minor
              Found in app/controllers/stories_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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  user = User.where(:email => params[:email]).first
                  if user && user.authenticate(params[:password])
                    if params[:remember_me]
                      cookies.permanent.signed[:user_id] = user.id
              Severity: Minor
              Found in app/controllers/sessions_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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  @user = User.find(params[:id])
              
                  if params[:cancel]
                    redirect_to @user, flash: { error: t('controllers.users.update.flash.canceled') }
              Severity: Minor
              Found in app/controllers/users_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

              Severity
              Category
              Status
              Source
              Language