bborn/communityengine

View on GitHub

Showing 147 of 147 total issues

Function Tracker has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var Tracker = (function () {
      var onMove = function () {},
          onDone = function () {},
          trackDoc = options.trackDocument;

Severity: Major
Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 3 hrs to fix

    Class Post has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Post < ActiveRecord::Base
      include Rakismet::Model
      rakismet_attrs :comment_type => 'post'
    
      acts_as_moderated_commentable
    Severity: Minor
    Found in app/models/post.rb - About 3 hrs to fix

      Method create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @user = User.find(params[:user_id])
          @post = Post.new(post_params)
          @post.user = @user
      
      
      Severity: Minor
      Found in app/controllers/posts_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 find_country_and_state_from_search_params has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_country_and_state_from_search_params(search)
          country     = Country.find(search['country_id']) if !search['country_id'].blank?
          state       = State.find(search['state_id']) if !search['state_id'].blank?
          metro_area  = MetroArea.find(search['metro_area_id']) if !search['metro_area_id'].blank?
      
      
      Severity: Minor
      Found in app/models/user.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

      Function KeyManager has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var KeyManager = (function () {
            var $keymgr = $('<input type="radio" />').css({
              position: 'fixed',
              left: '-120px',
              width: '12px'
      Severity: Major
      Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 2 hrs to fix

        Function createTag has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                createTag: function(value, additionalClass, duringInitialization) {
                    var that = this;
        
                    value = $.trim(value);
        
        
        Severity: Major
        Found in app/assets/javascripts/tag-it/tag-it.js - About 2 hrs to fix

          Method index has a Cognitive Complexity of 20 (exceeds 5 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 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 20 (exceeds 5 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 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 rss_feed_for has a Cognitive Complexity of 20 (exceeds 5 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 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 create has a Cognitive Complexity of 20 (exceeds 5 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 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 page_title has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def page_title
              divider = " | ".html_safe
          
              app_base = configatron.community_name
              tagline = " #{divider} #{configatron.community_tagline}"
          Severity: Major
          Found in app/helpers/base_helper.rb - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                                if (
                                    (event.which === $.ui.keyCode.COMMA && event.shiftKey === false) ||
                                    event.which === $.ui.keyCode.ENTER ||
                                    (
                                        event.which == $.ui.keyCode.TAB &&
            Severity: Critical
            Found in app/assets/javascripts/tag-it/tag-it.js - About 2 hrs to fix

              Method container_title has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def container_title
                  app_base = configatron.community_name
                  title = app_base
              
                  case controller.controller_name
              Severity: Major
              Found in app/helpers/base_helper.rb - About 2 hrs to fix

                Function getRect has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      function getRect() //{{{
                      {
                        var xsize = x2 - x1,
                            ysize = y2 - y1,
                            delta;
                Severity: Major
                Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 2 hrs to fix

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

                        function trackTouchMove(e) //{{{
                        {
                          e.pageX = e.originalEvent.changedTouches[0].pageX;
                          e.pageY = e.originalEvent.changedTouches[0].pageY;
                          return trackMove(e);
                  Severity: Major
                  Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 1202..1207

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

                  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 trackTouchEnd(e) //{{{
                        {
                          e.pageX = e.originalEvent.changedTouches[0].pageX;
                          e.pageY = e.originalEvent.changedTouches[0].pageY;
                          return trackUp(e);
                  Severity: Major
                  Found in app/assets/javascripts/jcrop/jquery.Jcrop.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/jcrop/jquery.Jcrop.js on lines 1195..1200

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

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

                      var Touch = (function () {
                        // Touch support detection function adapted (under MIT License)
                        // from code by Jeffrey Sambells - http://github.com/iamamused/
                        function hasTouchSupport() {
                          var support = {},
                  Severity: Major
                  Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 2 hrs to fix

                    Function animateTo has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function animateTo(a, callback) //{{{
                        {
                          var x1 = a[0] / xscale,
                              y1 = a[1] / yscale,
                              x2 = a[2] / xscale,
                    Severity: Minor
                    Found in app/assets/javascripts/jcrop/jquery.Jcrop.js - About 2 hrs to fix

                      Function parse has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              parse: function( red, green, blue, alpha ) {
                                  if ( red === undefined ) {
                                      this._rgba = [ null, null, null, null ];
                                      return this;
                                  }
                      Severity: Minor
                      Found in app/assets/javascripts/jcrop/jquery.color.js - About 1 hr to fix

                        Method setup_metro_area_choices_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def setup_metro_area_choices_for(object)
                            metro_areas = states = []
                            if object.metro_area
                              if object.is_a? Event
                                states = object.metro_area.country.states
                        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

                        Severity
                        Category
                        Status
                        Source
                        Language