bborn/communityengine

View on GitHub

Showing 147 of 147 total issues

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

  def delete_selected
    if params[:delete]
      params[:delete].each { |id|
        user = User.find(id)
        unless user.admin? || user.featured_writer?
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 destroy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @comment = Comment.find(params[:id])
    if @comment.can_be_deleted_by(current_user) && @comment.destroy
      if params[:spam] && configatron.has_key?(:akismet_key)
        @comment.spam!
Severity: Minor
Found in app/controllers/comments_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 show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    tag_array = ActsAsTaggableOn::DefaultParser.new( URI::decode(params[:id]) ).parse

    @tags = ActsAsTaggableOn::Tag.where('name IN (?)', tag_array )
    if @tags.nil? || @tags.empty?
Severity: Minor
Found in app/controllers/tags_controller.rb - About 1 hr to fix

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

      def deny
        @user = User.find(params[:user_id])
        @friendship = @user.friendships.find(params[:id])
    
        respond_to do |format|
    Severity: Major
    Found in app/controllers/friendships_controller.rb and 1 other location - About 1 hr to fix
    app/controllers/friendships_controller.rb on lines 20..32

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

    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 accept
        @user = User.find(params[:user_id])
        @friendship = @user.friendships_not_initiated_by_me.find(params[:id])
    
        respond_to do |format|
    Severity: Major
    Found in app/controllers/friendships_controller.rb and 1 other location - About 1 hr to fix
    app/controllers/friendships_controller.rb on lines 6..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 54.

    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 (xx < 0) {
                xx = 0;
                h = Math.abs((xx - x1) / aspect);
                yy = rh < 0 ? y1 - h : h + y1;
              } else if (xx > boundx) {
    Severity: Major
    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 568..576

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

    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

    Function to has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        spaces.hsla.to = function ( rgba ) {
            if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
                return [ null, null, null, rgba[ 3 ] ];
            }
            var r = rgba[ 0 ] / 255,
    Severity: Minor
    Found in app/assets/javascripts/jcrop/jquery.color.js - About 1 hr to fix

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

        def create
          @topic = Topic.includes(:forum).where(:id => params[:topic_id].to_i, :forum_id => params[:forum_id].to_i).first
          if @topic.locked?
            respond_to do |format|
              format.html do
      Severity: Minor
      Found in app/controllers/sb_posts_controller.rb - About 1 hr to fix

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

                  if (yy < 0) {
                    yy = 0;
                    w = Math.abs((yy - y1) * aspect);
                    xx = rw < 0 ? x1 - w : w + x1;
                  } else if (yy > boundy) {
        Severity: Major
        Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 555..563

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

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

          def create
            @user = current_user
            @photo = Photo.new(photo_params)
            @photo.user = @user
            @photo.tag_list = params[:tag_list] || ''
        Severity: Minor
        Found in app/controllers/photos_controller.rb - About 1 hr to fix

          Function transition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  transition: function( other, distance ) {
                      var end = color( other ),
                          spaceName = end._space(),
                          space = spaces[ spaceName ],
                          start = this[ space.cache ] || space.to( this._rgba ),
          Severity: Minor
          Found in app/assets/javascripts/jcrop/jquery.color.js - About 1 hr to fix

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

              def require_ownership_or_moderator
                @user ||= User.find(params[:user_id])
                @post ||= Post.unscoped.find(params[:id]) if params[:id]
                unless admin? || moderator? || (@post && (@post.user.eql?(current_user))) || (!@post && @user && @user.eql?(current_user))
                  redirect_to :controller => 'sessions', :action => 'new' and return false
            Severity: Minor
            Found in app/controllers/posts_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 send_to has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def send_to(email_addresses = '', message = '', user = nil)
                self.invalid_emails = []
                emails = email_addresses.split(",").collect{|email| email.strip }.uniq
                emails.each do |email|
                  self.invalid_emails << email unless email =~ /[\w._%-]+@[\w.-]+.[a-zA-Z]{2,4}/
            Severity: Minor
            Found in app/models/post.rb - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function removeTag has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    removeTag: function(tag, animate) {
                        animate = typeof animate === 'undefined' ? this.options.animate : animate;
            
                        tag = $(tag);
            
            
            Severity: Minor
            Found in app/assets/javascripts/tag-it/tag-it.js - About 1 hr to fix

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

                def create_photos
                  @photo = current_user.photos.new
                  file = params[:qqfile] ||params[:upload]
                  @photo.photo = Ckeditor::Http.normalize_param(file, request)
                  callback = ckeditor_before_create_asset(@photo)
              Severity: Minor
              Found in app/controllers/photos_controller.rb - About 1 hr to fix

                Function clean has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  jQuery.clean = function( elems, context, fragment, scripts ) {
                    // Set context per 1.8 logic
                    context = context || document;
                    context = !context.nodeType && context[0] || context;
                    context = context.ownerDocument || context;
                Severity: Minor
                Found in app/assets/javascripts/jquery.migrate.js - About 1 hr to fix

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

                    def update
                      @metro_areas, @states = setup_locations_for(@user)
                  
                      unless params[:metro_area_id].blank?
                        @user.metro_area  = MetroArea.find(params[:metro_area_id])
                  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

                          if ((nh > h) && h > 0) {
                            nh = h;
                            nw = (h / $obj.height()) * $obj.width();
                          }
                    Severity: Major
                    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 1 hr to fix
                    app/assets/javascripts/jcrop/jquery.Jcrop.js 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 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

                            if (xx < 0) {
                              x1 -= xx;
                              xx = 0;
                            } else if (xx > boundx) {
                              x1 -= xx - boundx;
                    Severity: Major
                    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 1 hr to fix
                    app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 612..618

                    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

                          if ((nw > w) && w > 0) {
                            nw = w;
                            nh = (w / $obj.width()) * $obj.height();
                          }
                    Severity: Major
                    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 1 hr to fix
                    app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 192..195

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language