roseweixel/lacquer-lover

View on GitHub

Showing 59 of 59 total issues

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

    $('.well').on('click', '#show', function() {
        $('.user-dashboard').slideDown();
        $('#show').hide();
    });
Severity: Minor
Found in app/assets/javascripts/users.js and 1 other location - About 45 mins to fix
app/assets/javascripts/users.js on lines 41..44

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 send_transactional_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def send_transactional_message
    if params[:reply_address] == current_user.email
      reply_address = "#{current_user.name} via Lacquer Love&Lend <#{params[:reply_address]}>"
    elsif params[:reply_address] == "do not provide a reply address"
      reply_address = "#{current_user.name} via Lacquer Love&Lend <noreply@lacquerloveandlend.com>"
Severity: Minor
Found in app/controllers/users_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

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

  $(document).on('mouseenter mouseleave', '#add-friends', function(){
    $('img#profile').toggle();
    $('img#profile-add-friends').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 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', '#make-loanable', function(){
    $('img#profile').toggle();
    $('img#profile-make-loanable').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 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 2 locations. Consider refactoring.
Open

    $('.well').on('click', '#hide', function() {
        $('.user-dashboard').slideUp();
        $('#show').show();
    });
Severity: Minor
Found in app/assets/javascripts/users.js and 1 other location - About 45 mins to fix
app/assets/javascripts/users.js on lines 46..49

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 user_feedback_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def user_feedback_email(reply_address, to_address, subject, body, bcc)
Severity: Minor
Found in app/mailers/user_mailer.rb - About 35 mins to fix

    Method swatch_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def swatch_image
        user = User.find(user_id)
        lacquer = Lacquer.find(self.lacquer_id)
        if lacquer.swatches.any?
          lacquer.swatches.each do |swatch|
    Severity: Minor
    Found in app/models/user_lacquer.rb - About 35 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 fuzzy_find_by_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.fuzzy_find_by_name(search_term)
        search_words = search_term.downcase.split(" ")
        search_word_ids = Word.where(text: search_words).pluck(:id)
        lacquer_ids = LacquerWord.where(word_id: search_word_ids).pluck(:lacquer_id)
    
    
    Severity: Minor
    Found in app/models/lacquer.rb - About 35 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

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

                        [ d[i-1][j]+1,    # deletion
                          d[i][j-1]+1,    # insertion
                          d[i-1][j-1]+1,  # substitution
                        ].min
    Severity: Minor
    Found in app/models/word.rb and 1 other location - About 25 mins to fix
    app/models/lacquer.rb on lines 188..191

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

    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

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

                        [ d[i-1][j]+1,    # deletion
                          d[i][j-1]+1,    # insertion
                          d[i-1][j-1]+1,  # substitution
                        ].min
    Severity: Minor
    Found in app/models/lacquer.rb and 1 other location - About 25 mins to fix
    app/models/word.rb on lines 36..39

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

    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 levenshtein_distance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def levenshtein_distance(string)
        string.downcase!
        m = string.length
        n = text.length
        return m if n == 0
    Severity: Minor
    Found in app/models/word.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 display_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def display_image(user_lacquer)
        if user_lacquer.selected_display_image && user_lacquer.selected_display_image == user_lacquer.lacquer.default_picture
          picture_for(user_lacquer.lacquer)
        else
          image = user_lacquer.selected_display_image || user_lacquer.swatch_image
    Severity: Minor
    Found in app/helpers/application_helper.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
        begin
          @friendship.update(state: params[:state])
        rescue
          flash[:alert] = "Sorry, we can't seem to find the friendship you were trying to update!"
    Severity: Minor
    Found in app/controllers/friendships_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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def destroy
        user = User.find(@user_lacquer.user_id)
        @lacquer = Lacquer.find(@user_lacquer.lacquer_id)
        if user == current_user
          @user_lacquer.destroy
    Severity: Minor
    Found in app/controllers/user_lacquers_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 levenshtein_distance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def levenshtein_distance(string)
        string.downcase!
        text = name.downcase
        m = string.length
        n = text.length
    Severity: Minor
    Found in app/models/lacquer.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

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

      def friend_request_notification(user, friend)
        @user = user
        @friend = friend
        @friend_url = "http://www.lacquerloveandlend.com/friendships/new?friend_id=#{@user.id}"
    
    
    Severity: Minor
    Found in app/mailers/user_mailer.rb and 1 other location - About 15 mins to fix
    app/mailers/user_mailer.rb on lines 42..49

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

    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 friend_request_accepted_notification(user, friend)
        @user = user
        @friend = friend
        @friend_url = "http://www.lacquerloveandlend.com/users/#{@friend.id}"
    
    
    Severity: Minor
    Found in app/mailers/user_mailer.rb and 1 other location - About 15 mins to fix
    app/mailers/user_mailer.rb on lines 31..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 26.

    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 color_tags
        colors = []
        @user_lacquers = UserLacquer.where(:lacquer_id => self.id)
        @user_lacquers.each do |user_lacquer|
          user_lacquer.colors.each do |color|
    Severity: Minor
    Found in app/models/lacquer.rb and 1 other location - About 15 mins to fix
    app/models/lacquer.rb on lines 236..244

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

    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 finish_tags
        finishes = []
        @user_lacquers = UserLacquer.where(:lacquer_id => self.id)
        @user_lacquers.each do |user_lacquer|
          user_lacquer.finishes.each do |finish|
    Severity: Minor
    Found in app/models/lacquer.rb and 1 other location - About 15 mins to fix
    app/models/lacquer.rb on lines 210..218

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

    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

    Severity
    Category
    Status
    Source
    Language