bborn/communityengine

View on GitHub

Showing 106 of 147 total issues

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

        Method build_conditions_for_search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.build_conditions_for_search(search)
            user = User.arel_table
            users = User.active
            if search['country_id'] && !(search['metro_area_id'] || search['state_id'])
              users = users.where(user[:country_id].eq(search['country_id']))
        Severity: Minor
        Found in app/models/user.rb - About 55 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

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

          def create
            @event = Event.new(event_params)
            @event.user = current_user
            if params[:metro_area_id]
              @event.metro_area = MetroArea.find(params[:metro_area_id])
        Severity: Minor
        Found in app/controllers/events_controller.rb - About 55 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

        Method update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @event = Event.find(params[:id])
            if params[:metro_area_id]
              @event.metro_area = MetroArea.find(params[:metro_area_id])
            else
        Severity: Minor
        Found in app/controllers/events_controller.rb - About 55 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

        Method get_sorted_langs_from_accept_header has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_sorted_langs_from_accept_header
            accept_langs = (request.env['HTTP_ACCEPT_LANGUAGE'] || "en-us,en;q=0.5").split(/,/) rescue nil
            return nil unless accept_langs
        
            # Extract langs and sort by weight
        Severity: Minor
        Found in lib/community_engine/localized_application.rb - About 55 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

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

          def delete_selected
            if request.post?
              if params[:delete]
                params[:delete].each { |id|
                  @message = Message.where("messages.id = ? AND (sender_id = ? OR recipient_id = ?)", id, @user, @user).first
        Severity: Minor
        Found in app/controllers/messages_controller.rb - About 45 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

        Avoid deeply nested control flow statements.
        Open

                  if ( typeof elem.getElementsByTagName !== "undefined" ) {
                    // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
                    jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
        
                    // Splice the scripts into ret after their former ancestor and advance our index beyond them
        Severity: Major
        Found in app/assets/javascripts/jquery.migrate.js - About 45 mins to fix

          Method create_photos has a Cognitive Complexity of 8 (exceeds 5 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 45 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

          Method find_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_user
                if @user = User.active.find(params[:user_id] || params[:id])
                  @is_current_user = (@user && @user.eql?(current_user))
                  unless logged_in? || @user.profile_public?
                    flash[:error] = :private_user_profile_message.l
          Severity: Minor
          Found in app/controllers/base_controller.rb - About 45 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

          Method get_plugins_to_migrate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_plugins_to_migrate(plugin_names)
          
                # First, grab all the plugins which exist and have migrations
                @plugins_to_migrate = if plugin_names.empty?
                  Desert::Manager.plugins
          Severity: Minor
          Found in generators/plugin_migration/plugin_migration_generator.rb - About 45 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

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

            def create
              @user = current_user
          
              @invitation = Invitation.new(invitation_params)
              @invitation.user = @user
          Severity: Minor
          Found in app/controllers/invitations_controller.rb - About 45 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

          Consider simplifying this complex logical expression.
          Open

                              if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
                                  curElem = hook === "backgroundColor" ? elem.parentNode : elem;
                                  do {
                                      backgroundColor = jQuery.curCSS( curElem, "backgroundColor" );
                                  } while (
          Severity: Major
          Found in app/assets/javascripts/jcrop/jquery.color.js - About 40 mins to fix

            Function remove has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
            Severity: Minor
            Found in app/assets/javascripts/jquery.migrate.js - About 35 mins to fix

              Function add has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              jQuery.event.add = function( elem, types, handler, data, selector ){
              Severity: Minor
              Found in app/assets/javascripts/jquery.migrate.js - About 35 mins to fix

                Method post_recommendation has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def post_recommendation(name, email, post, message = nil, current_user = nil)
                Severity: Minor
                Found in app/models/user_notifier.rb - About 35 mins to fix

                  Method create has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                  Method assign_protected has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def assign_protected
                        @topic.sticky = @topic.locked = 0
                        @topic.forum_id = @forum.id
                        @topic.user = current_user if @topic.new_record?
                  
                  
                  Severity: Minor
                  Found in app/controllers/topics_controller.rb - About 35 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

                  Method acts_as_activity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def acts_as_activity(actor, options = {})
                        unless included_modules.include? InstanceMethods
                          after_create do |record|
                            unless options[:if].kind_of?(Proc) and not options[:if].call(record)
                              record.create_activity_from_self 
                  Severity: Minor
                  Found in lib/activity_tracker/activity_tracker.rb - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language