roseweixel/lacquer-lover

View on GitHub

Showing 59 of 59 total issues

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

  $('.colors').click(function(e){
    e.preventDefault();
    e.stopPropagation();
    $('table h2').hide();

Severity: Major
Found in app/assets/javascripts/user_lacquers.js and 1 other location - About 4 days to fix
app/assets/javascripts/user_lacquers.js on lines 148..216

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 692.

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

  $('.finishes').click(function(e){
    e.preventDefault();
    e.stopPropagation();
    $('table h2').hide();

Severity: Major
Found in app/assets/javascripts/user_lacquers.js and 1 other location - About 4 days to fix
app/assets/javascripts/user_lacquers.js on lines 78..146

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 692.

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

  $('.toggle-favorites').click(function(){
    if ($(this).parent('.selected').length > 0) {
      $(this).parent().removeClass('selected');
      $(this).parent().parent().siblings('.brand-favorites').slideUp();
    } else {
Severity: Major
Found in app/assets/javascripts/brands_index.js and 1 other location - About 1 day to fix
app/assets/javascripts/brands_index.js on lines 2..18

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 326.

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

  $('.toggle-users').click(function(){
    if ($(this).parent('.selected').length > 0) {
      $(this).parent().removeClass('selected');
      $(this).parent().parent().siblings('.brand-lacquer-lovers').slideUp();
    } else {
Severity: Major
Found in app/assets/javascripts/brands_index.js and 1 other location - About 1 day to fix
app/assets/javascripts/brands_index.js on lines 20..36

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 326.

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

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

class User < ActiveRecord::Base
  has_many :user_lacquers, -> { order(:updated_at => :desc) }, dependent: :destroy
  has_many :lacquers, through: :user_lacquers
  has_many :brands, -> { uniq }, through: :lacquers
  
Severity: Minor
Found in app/models/user.rb - About 4 hrs to fix

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

      brandSorterReverse.click(function(e){
        $('#user-lacquers-by-default').hide();
        $('#user-lacquers-by-brand').hide();
        $('#user-lacquers-by-name').hide();
        $('#user-lacquers-by-name-reverse').hide();
    Severity: Major
    Found in app/assets/javascripts/user_lacquers.js and 2 other locations - About 2 hrs to fix
    app/assets/javascripts/user_lacquers.js on lines 226..232
    app/assets/javascripts/user_lacquers.js on lines 248..254

    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 87.

    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 3 locations. Consider refactoring.
    Open

      nameSorterReverse.click(function(e){
        $('#user-lacquers-by-default').hide();
        $('#user-lacquers-by-brand').hide();
        $('#user-lacquers-by-name').hide();
        $('#user-lacquers-by-brand-reverse').hide();
    Severity: Major
    Found in app/assets/javascripts/user_lacquers.js and 2 other locations - About 2 hrs to fix
    app/assets/javascripts/user_lacquers.js on lines 226..232
    app/assets/javascripts/user_lacquers.js on lines 241..247

    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 87.

    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 3 locations. Consider refactoring.
    Open

      brandSorter.click(function(e){
        $('#user-lacquers-by-default').hide();
        $('#user-lacquers-by-name').hide();
        $('#user-lacquers-by-brand-reverse').hide();
        $('#user-lacquers-by-name-reverse').hide();
    Severity: Major
    Found in app/assets/javascripts/user_lacquers.js and 2 other locations - About 2 hrs to fix
    app/assets/javascripts/user_lacquers.js on lines 241..247
    app/assets/javascripts/user_lacquers.js on lines 248..254

    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 87.

    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

    Class Lacquer has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Lacquer < ActiveRecord::Base
      belongs_to :brand
      has_many :user_lacquers, dependent: :destroy
      has_many :colors, through: :user_lacquers
      has_many :finishes, through: :user_lacquers
    Severity: Minor
    Found in app/models/lacquer.rb - About 2 hrs to fix

      Method create has a Cognitive Complexity of 18 (exceeds 5 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 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 update has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @transaction = Transaction.find(params[:id])
          original_state = @transaction.state
          if params[:state]
            @transaction.update(state: params[:state])
      Severity: Minor
      Found in app/controllers/transactions_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 large_picture_for has a Cognitive Complexity of 16 (exceeds 5 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 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 small_picture_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def small_picture_for(lacquer)
          if lacquer.picture && valid?(lacquer.picture)
            begin
              if lacquer.brand.name == "Deborah Lippmann" 
                image_tag(lacquer.picture, :size => "31x50", :class => "padded_lacquer_pic_small")
      Severity: Minor
      Found in app/helpers/application_helper.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 picture_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def picture_for(lacquer)
          if lacquer.picture && valid?(lacquer.picture)
            begin 
              if lacquer.brand.name == "Zoya" || lacquer.brand.name == "Nars" || lacquer.brand.name == "I Love Nail Polish (ILNP)" || lacquer.brand.name == "Formula X by Sephora"
                image_tag(lacquer.picture, :size => "90x90", :class => "chunky_image")
      Severity: Minor
      Found in app/helpers/application_helper.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 edit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def edit
          session[:originated_from_uri] = request.env["HTTP_REFERER"] if request.env["HTTP_REFERER"]
          if !current_user
            flash[:alert] = "You must be signed in to edit a lacquer!"
            redirect_to root_path
      Severity: Minor
      Found in app/controllers/lacquers_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 new_transactional_message has a Cognitive Complexity of 14 (exceeds 5 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

      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 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @user_lacquer = UserLacquer.find(params[:lacquer][:user_lacquer_id])
      
          if @lacquer.user_added_by_id != @user.id && params[:lacquer][:name] || params[:lacquer][:brand_id]
            flash[:alert] = "You do not have permission to change the name or brand of this lacquer."
      Severity: Minor
      Found in app/controllers/lacquers_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 new has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def new
          if !@user && request.env['REQUEST_URI']
            if request.env['REQUEST_URI'].scan(/(?<=friend_id=)\d+/)[0]
              session[:intended_uri] = request.env['REQUEST_URI']
              @friend = User.find("#{session[:intended_uri].scan(/(?<=friend_id=)\d+/)[0]}")
      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

      Method update has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update
          @transaction = Transaction.find(params[:id])
          original_state = @transaction.state
          if params[:state]
            @transaction.update(state: params[:state])
      Severity: Minor
      Found in app/controllers/transactions_controller.rb - About 1 hr to fix

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

          def send_feedback_email
            if current_user && params[:reply_address] == current_user.email
              reply_address = "#{current_user.name} <#{params[:reply_address]}>"
            elsif is_an_email_address?(params[:other_reply_address])
              reply_address = params[:other_reply_address]
        Severity: Minor
        Found in app/controllers/static_pages_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