fablabbcn/fablabs

View on GitHub

Showing 16 of 31 total issues

Class User has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base

  has_many :access_grants, class_name: "Doorkeeper::AccessGrant",
                           foreign_key: :resource_owner_id,
                           dependent: :delete_all # or :destroy if you need callbacks
Severity: Minor
Found in app/models/user.rb - About 4 hrs to fix

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

    class Lab < ApplicationRecord
      include RocketPants::Cacheable
      include Authority::Abilities
      include Workflow
      include WorkflowActiverecord
    Severity: Minor
    Found in app/models/lab.rb - About 3 hrs to fix

      Method included has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.included(base)
          base.workflow_column :workflow_state
      
          base.workflow do
            state :unverified do
      Severity: Major
      Found in app/models/concerns/approve_workflow.rb - About 2 hrs to fix

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

          def self.parse(payload, sso_secret = nil)
            sso = new
            sso.sso_secret = sso_secret if sso_secret
        
            parsed = Rack::Utils.parse_query(payload)
        Severity: Minor
        Found in app/lib/single_sign_on.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 lab_params has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def lab_params
            params.require(:lab).permit(
              :activity_status,
              :activity_start_at,
              :activity_inaugurated_at,
        Severity: Minor
        Found in app/controllers/labs_controller.rb - About 1 hr to fix

          Method parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.parse(payload, sso_secret = nil)
              sso = new
              sso.sso_secret = sso_secret if sso_secret
          
              parsed = Rack::Utils.parse_query(payload)
          Severity: Minor
          Found in app/lib/single_sign_on.rb - About 1 hr to fix

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

              def url_icon(url)
                case url
                when /twitter\.com/
                  icon('twitter')
                when /github\.com/
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 1 hr to fix

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

                  def project_params
                    attributes = [
                      :type,
                      :title,
                      :description,
              Severity: Minor
              Found in app/controllers/projects_controller.rb - About 1 hr to fix

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

                  def create
                    return render plain: "Please go back and ensure that the 'ignore' field is EMPTY." if params[:name].present?
                
                    logger.info 'Creating user through Users controller'
                
                
                Severity: Minor
                Found in app/controllers/users_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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def update
                    @user = current_user
                    authorize_action_for @user
                    email_changed = (@user.email != user_params[:email])
                    if email_changed
                Severity: Minor
                Found in app/controllers/users_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 generate_fab10_coupon_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def generate_fab10_coupon_code
                    if self.fab10_coupon_code.blank?
                      self.fab10_coupon_code = loop do
                        random_token = SecureRandom.urlsafe_base64[0..10].gsub(/[^0-9a-zA-Z]/i, '')
                        break random_token unless User.exists?(fab10_coupon_code: random_token)
                Severity: Minor
                Found in app/models/user.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

                Avoid too many return statements within this method.
                Open

                      return 0
                Severity: Major
                Found in app/models/concerns/lab_approve_methods.rb - About 30 mins to fix

                  Method consensus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def consensus
                      votes_up = referee_approval_processes.where(approved: true).count
                      votes_down = referee_approval_processes.where(approved: false).count
                      if votes_up >= 2
                        update_attributes(workflow_state: :approved)
                  Severity: Minor
                  Found in app/models/concerns/lab_approve_methods.rb - About 25 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 require_admin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def require_admin
                      if current_user
                        unless superadmin or referee
                          return redirect_to root_url, notice: "Not authorized"
                        end
                  Severity: Minor
                  Found in app/controllers/backstage/backstage_controller.rb - About 25 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 guardian has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def guardian
                      votes_up = referee_approval_processes.where(approved: true).count
                      votes_down = referee_approval_processes.where(approved: false).count
                      if votes_up >= 2
                        return 1
                  Severity: Minor
                  Found in app/models/concerns/lab_approve_methods.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def update
                      @recovery = Recovery.where(key: params[:id]).first
                      user_params = recovery_params[:user_attributes].slice(:password, :password_confirmation)
                      if @recovery.user and user_params[:password].present?
                        if @recovery.user.update_attributes user_params
                  Severity: Minor
                  Found in app/controllers/recoveries_controller.rb - About 25 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