bborn/communityengine

View on GitHub

Showing 147 of 147 total issues

Method index has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    commentable_type = get_commentable_type(params[:commentable_type])
    commentable_class = commentable_type.singularize.constantize
    commentable_type_humanized = commentable_type.humanize
    commentable_type_tableized = commentable_type.tableize
Severity: Minor
Found in app/controllers/comments_controller.rb - About 1 hr to fix

    Function interfaceUpdate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function interfaceUpdate(alt) //{{{
        // This method tweaks the interface based on options object.
        // Called when options are changed and at end of initialization.
        {
          if (options.allowResize) {
    Severity: Minor
    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 1 hr to fix

      Method metro_area_update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def metro_area_update
      
          country = Country.find(params[:country_id]) unless params[:country_id].blank?
          state   = State.find(params[:state_id]) unless params[:state_id].blank?
          states  = country ? country.states : []
      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 create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @user = current_user
          @clipping = @user.clippings.new(clipping_params)
          @clipping.user = @user
          @clipping.tag_list = params[:tag_list] || ''
      Severity: Minor
      Found in app/controllers/clippings_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

      Function attr has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      jQuery.attr = function( elem, name, value, pass ) {
        var lowerName = name.toLowerCase(),
          nType = elem && elem.nodeType;
      
        if ( pass ) {
      Severity: Minor
      Found in app/assets/javascripts/jquery.migrate.js - About 1 hr to fix

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

              function createHandles(li) //{{{
              {
                var i;
                for (i = 0; i < li.length; i++) {
                  handle[li[i]] = insertHandle(li[i]);
        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 910..916

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

        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

                  $.Jcrop.Loader(this,function(){
                    $(this).css({display:'block',visibility:'hidden'});
                    api = $.Jcrop(this, options);
                    if ($.isFunction(callback)) callback.call(api);
                  });
        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 1609..1613

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

        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

                else {
                  $(this).css({display:'block',visibility:'hidden'});
                  api = $.Jcrop(this, options);
                  if ($.isFunction(callback)) callback.call(api);
                }
        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 1604..1608

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

        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

              function createDragbars(li) //{{{
              {
                var i;
                for (i = 0; i < li.length; i++) {
                  dragbar[li[i]] = insertDragbar(li[i]);
        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 932..938

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

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

        function cropInit() {
          croppable_name = '#' + croppable_id;    
          preview_name = '#' + preview_id;    
            
          // Copy the image, and insert it in an offscreen DIV
        Severity: Minor
        Found in app/assets/javascripts/cropper.js - About 1 hr to fix

          Function destroy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  destroy: function() {
                      $.Widget.prototype.destroy.call(this);
          
                      this.element.unbind('.tagit');
                      this.tagList.unbind('.tagit');
          Severity: Minor
          Found in app/assets/javascripts/tag-it/tag-it.js - About 1 hr to fix

            Method rss_feed_for has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def rss_feed_for(resources, options = {})
                  xml = Builder::XmlMarkup.new(:indent => 2)
            
                  options[:feed]       ||= {}
                  options[:item]       ||= {}
            Severity: Minor
            Found in lib/resource_feeder/rss.rb - About 1 hr to fix

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

                      if (ymin / yscale && (Math.abs(ysize) < ymin / yscale)) {
                        y2 = (ysize > 0) ? (y1 + ymin / yscale) : (y1 - ymin / yscale);
                      }
              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 675..677

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

              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 (xmin / xscale && (Math.abs(xsize) < xmin / xscale)) {
                        x2 = (xsize > 0) ? (x1 + xmin / xscale) : (x1 - xmin / xscale);
                      }
              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 672..674

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

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

                  def atom_feed_for(resources, options = {})
                    xml = Builder::XmlMarkup.new(:indent => 2)
              
                    options[:feed]       ||= {}
                    options[:item]       ||= {}
              Severity: Minor
              Found in lib/resource_feeder/atom.rb - About 1 hr to fix

                Method ical has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def ical
                    @calendar = RiCal.Calendar
                    @calendar.add_x_property 'X-WR-CALNAME', configatron.community_name
                    @calendar.add_x_property 'X-WR-CALDESC', "#{configatron.community_name} #{:events.l}"
                    Event.all.each do |ce_event|
                Severity: Minor
                Found in app/controllers/events_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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def show
                    respond_to do |format|
                      format.html do
                        # see notes in base_controller.rb on how this works
                        current_user.update_last_seen_at if logged_in?
                Severity: Minor
                Found in app/controllers/topics_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 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def destroy
                    @user = User.find(params[:id])
                    unless @user.admin? || @user.featured_writer?
                      @user.spam! if params[:spam] && configatron.has_key?(:akismet_key)
                      @user.destroy
                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

                Function dragmodeHandler has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function dragmodeHandler(mode, f) //{{{
                    {
                      return function (pos) {
                        if (!options.aspectRatio) {
                          switch (mode) {
                Severity: Minor
                Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                      unless admin? || moderator? || (@post && (@post.user.eql?(current_user))) || (!@post && @user && @user.eql?(current_user))
                        redirect_to :controller => 'sessions', :action => 'new' and return false
                      end
                  Severity: Critical
                  Found in app/controllers/posts_controller.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language