gistflow/gistflow

View on GitHub

Showing 15 of 15 total issues

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

class User < ActiveRecord::Base
  include Models::Todolistable

  delegate :token, to: :account_token

Severity: Minor
Found in app/models/user.rb - About 4 hrs to fix

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

      $('a.subscribe').each(function(i, link_html){
        var link = $(link_html)
        if (window.current_user) {
          if (_.include(window.current_user.subscriptions, parseInt(link.data('id')))) {
            link.data('method', 'delete').addClass('active')
    Severity: Major
    Found in app/assets/javascripts/buttons.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/buttons.js on lines 60..67

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

    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

      $('a.follow').each(function(i, link_html){
        var link = $(link_html)
        if (window.current_user) {
          if (_.include(window.current_user.following, parseInt(link.data('id')))) {
            link.data('method', 'delete').html('Unfollow')
    Severity: Major
    Found in app/assets/javascripts/buttons.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/buttons.js on lines 70..77

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

    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

        if (window.current_user) {
          if (_.include(window.current_user.observings, post_data.id)) {
            observe.data('method', 'delete').removeClass('icon-eye-close')
              .addClass('icon-eye-open').attr('title', 'Unobserve')
          }
    Severity: Major
    Found in app/assets/javascripts/buttons.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/buttons.js on lines 49..56

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

    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

        if (window.current_user) {
          if (_.include(window.current_user.bookmarks, post_data.id)) {
            bookmark.data('method', 'delete').removeClass('icon-bookmark-empty')
              .addClass('icon-bookmark').attr('title', 'Unbookmark')
          }
    Severity: Major
    Found in app/assets/javascripts/buttons.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/buttons.js on lines 38..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 69.

    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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(user)
        # simple authorization like self.current_user = User.first
        can :create, :sessions if development?
        
        can :show, :sitemap
    Severity: Minor
    Found in app/models/ability.rb - About 1 hr to fix

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

        def self.find_or_create_by_omniauth(omniauth)
          token = omniauth['credentials']['token']
          ActiveRecord::Base.transaction do
            find_by_github_id(omniauth['uid']) || create! do |account|
              account.token     = token
      Severity: Minor
      Found in app/models/account/github.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 safe_replace has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def safe_replace
          # extract replaceable tags
          replaceable = {}
          REPLACEABLE_TAGS.each do |tag|
            @html.gsub!(%r{<#{tag}>.*?</#{tag}>}m) do |match|
      Severity: Minor
      Found in app/models/replaceable.rb - About 1 hr to fix

        Method show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            if @tag = Tag.find_by_name(params[:id])
              redirect_to @tag.entity if @tag.alias?
              
              @posts = Post.not_private.tagged_with(@tag.name).page(params[:page])
        Severity: Minor
        Found in app/controllers/tags_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

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

          def update
            @profile = current_user.profile
            if @profile.update_attributes(params[:profile])
              render json: {}, status: :ok
            else
        Severity: Minor
        Found in app/controllers/account/profiles_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/account/settings_controller.rb on lines 9..15

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

        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 update
            @settings = current_user.settings
            if @settings.update_attributes(params[:settings])
              render json: {}, status: :ok
            else
        Severity: Minor
        Found in app/controllers/account/settings_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/account/profiles_controller.rb on lines 5..11

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

        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 create
            @user = find_user(params[:user_id])
            current_user.follow(@user)
            link = render_to_string(inline: "<%= link_to_unfollow(@user) %>")
            render json: { 
        Severity: Minor
        Found in app/controllers/account/followings_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/account/followings_controller.rb on lines 18..28

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

        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 destroy
            @user = find_user(params[:user_id])
            current_user.unfollow(@user)
            link = render_to_string(inline: "<%= link_to_follow(@user) %>")
            render json: { 
        Severity: Minor
        Found in app/controllers/account/followings_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/account/followings_controller.rb on lines 5..16

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

        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 build
            @post = find_post(params[:post_id])
            @comment = @post.comments.build(params[:comment]) do |comment|
              comment.user = current_user
            end
        Severity: Minor
        Found in app/controllers/posts/comments_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/posts/comments_controller.rb on lines 29..35

        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 preview
            @post = find_post(params[:post_id])
            @comment = @post.comments.build(params[:comment]) do |comment|
              comment.user = current_user
            end
        Severity: Minor
        Found in app/controllers/posts/comments_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/posts/comments_controller.rb on lines 21..27

        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

        Severity
        Category
        Status
        Source
        Language