bborn/communityengine

View on GitHub

Showing 106 of 147 total issues

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

              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

                    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

                        Severity
                        Category
                        Status
                        Source
                        Language