roseweixel/lacquer-lover

View on GitHub

Showing 59 of 59 total issues

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

  def create
    if request.env['omniauth.auth'].present?
      existing_user = User.find_by(uid: request.env['omniauth.auth']['uid'])
      user = User.from_omniauth(request.env['omniauth.auth'])
      session[:user_id] = user.id
Severity: Minor
Found in app/controllers/sessions_controller.rb - About 1 hr to fix

    Method show has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def show
        if current_user
          [{"OPI" => [@new_opi_lacquer, @opi_lacquers]}, {"Essie" => [@new_essie_lacquer, @essie_lacquers]}, {"Butter London" => [@new_butter_lacquer, @butter_lacquers]}, {"Deborah Lippmann" => [@new_deborah_lacquer, @deborah_lacquers]}].each do |brand_hash|
            brand_hash.each do |brand, variables|
              if !Brand.where(name: brand).empty?
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 1 hr to fix

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

        def update
          if current_user && @review.user.id == current_user.id
            if @review.update(review_params)
              flash[:notice] = "Your review for #{@review.lacquer.name} was successfully updated!"
            else
      Severity: Minor
      Found in app/controllers/reviews_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 invite_friends has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def invite_friends
          if !@user
            flash[:alert] = "You need to be logged in to invite friends!"
            redirect_to :back
          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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              elsif lacquer.brand.name == "China Glaze"
                image_tag(lacquer.picture, :size => "39x90", :class => "padded_lacquer_pic")
              elsif lacquer.brand.name == "Deborah Lippmann"
                image_tag(lacquer.picture, :size => "55x90", :class => "padded_lacquer_pic")
              elsif lacquer.brand.name == "Butter London"
      Severity: Major
      Found in app/helpers/application_helper.rb and 1 other location - About 1 hr to fix
      app/helpers/application_helper.rb on lines 186..194

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        def create
          if params[:friendship] && params[:friendship].has_key?(:friend_id)
            @friend = User.find(params[:friendship][:friend_id])
            @friendship = Friendship.new(friend: @friend, user: @user)
            if @friendship.save
      Severity: Minor
      Found in app/controllers/friendships_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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              elsif lacquer.brand.name == "China Glaze"
                image_tag(lacquer.picture, :size => "22x50", :class => "padded_lacquer_pic_small")
              elsif lacquer.brand.name == "Essie"
                image_tag(lacquer.picture, :size => "23x50", :class => "padded_lacquer_pic_small")
              elsif lacquer.brand.name == "Nails Inc."
      Severity: Major
      Found in app/helpers/application_helper.rb and 1 other location - About 1 hr to fix
      app/helpers/application_helper.rb on lines 126..134

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method large_picture_for has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def large_picture_for(lacquer)
          if lacquer.picture && valid?(lacquer.picture)
            begin
              if lacquer.brand.name == "Deborah Lippmann" 
                image_tag(lacquer.picture, :size => "360x360", :class => "padded_lacquer_pic_large deborah")
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def actually_works?(link)
            begin
              if link.start_with?("lacquers/")
                return false
              elsif link.class == Paperclip::Attachment || !link.start_with?("http")
        Severity: Major
        Found in app/models/lacquer.rb and 1 other location - About 1 hr to fix
        app/helpers/application_helper.rb on lines 96..113

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def valid?(url)
            begin
              if url.start_with?("lacquers/")
                return false
              elsif url.class == Paperclip::Attachment || !url.start_with?("http")
        Severity: Major
        Found in app/helpers/application_helper.rb and 1 other location - About 1 hr to fix
        app/models/lacquer.rb on lines 52..69

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          def new_transactional_message
            if !@user
              if request.env['REQUEST_URI']
                session[:intended_uri] = request.env['REQUEST_URI']
                flash[:notice] = %Q[ #{ view_context.link_to("Sign in", login_path, id:"brand-show-sign-in", class:'light-blue-link')} to send a message! ]
        Severity: Minor
        Found in app/controllers/users_controller.rb - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            $('#new-invite-link').click(function(e){
              e.stopPropagation();
              e.preventDefault();
          
              $('#hidden-invite-modal-link').click();
          Severity: Major
          Found in app/assets/javascripts/static_pages.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/static_pages.js on lines 33..38

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 55.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            $('.contact-link').click(function(e){
              e.stopPropagation();
              e.preventDefault();
          
              $('#hidden-contact-modal-link').click();
          Severity: Major
          Found in app/assets/javascripts/static_pages.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/static_pages.js on lines 40..45

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 55.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            def create
              lacquer = Lacquer.new(name: params[:lacquer][:name], brand_id: params[:lacquer][:brand_id])
              lacquer.user_added_by_id = params[:lacquer][:user_added_by_id] if params[:lacquer][:user_added_by_id]
              lacquer.save
              if lacquer.errors.any?
          Severity: Minor
          Found in app/controllers/lacquers_controller.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def show
              if current_user
                [{"OPI" => [@new_opi_lacquer, @opi_lacquers]}, {"Essie" => [@new_essie_lacquer, @essie_lacquers]}, {"Butter London" => [@new_butter_lacquer, @butter_lacquers]}, {"Deborah Lippmann" => [@new_deborah_lacquer, @deborah_lacquers]}].each do |brand_hash|
                  brand_hash.each do |brand, variables|
                    if !Brand.where(name: brand).empty?
          Severity: Minor
          Found in app/controllers/users_controller.rb - About 55 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 transactional_message has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def transactional_message(from_name, bcc_email, reply_address, to_address, subject, body, transaction_id)
          Severity: Major
          Found in app/mailers/user_mailer.rb - About 50 mins to fix

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              $(document).on('mouseenter mouseleave', '#add-lacquers', function(){
                $('img#profile').toggle();
                $('img#profile-add-lacquers').toggle();
            
              });
            Severity: Major
            Found in app/assets/javascripts/static_pages.js and 4 other locations - About 45 mins to fix
            app/assets/javascripts/static_pages.js on lines 53..57
            app/assets/javascripts/static_pages.js on lines 59..63
            app/assets/javascripts/static_pages.js on lines 65..69
            app/assets/javascripts/static_pages.js on lines 71..75

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              $(document).on('mouseenter mouseleave', '#filter-lacquers', function(){
                $('img#profile').toggle();
                $('img#profile-filter-lacquers').toggle();
            
              });
            Severity: Major
            Found in app/assets/javascripts/static_pages.js and 4 other locations - About 45 mins to fix
            app/assets/javascripts/static_pages.js on lines 47..51
            app/assets/javascripts/static_pages.js on lines 59..63
            app/assets/javascripts/static_pages.js on lines 65..69
            app/assets/javascripts/static_pages.js on lines 71..75

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

              $(document).on('mouseenter mouseleave', '#borrow-it', function(){
                $('img#profile').toggle();
                $('img#profile-borrow-it').toggle();
            
              });
            Severity: Major
            Found in app/assets/javascripts/static_pages.js and 4 other locations - About 45 mins to fix
            app/assets/javascripts/static_pages.js on lines 47..51
            app/assets/javascripts/static_pages.js on lines 53..57
            app/assets/javascripts/static_pages.js on lines 59..63
            app/assets/javascripts/static_pages.js on lines 65..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

              def update
                @gift = Gift.find(params[:id])
                @gift.state == 'completed' ? completed_already = true : completed_already = false
                @gift.update(gift_params)
                if !completed_already && @gift.state == 'completed'
            Severity: Minor
            Found in app/controllers/gifts_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

            Severity
            Category
            Status
            Source
            Language