fablabbcn/fablabs

View on GitHub

Showing 31 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

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

                      state :unverified do
                        event :referee_approves, transition_to: :referee_approval
                        event :request_more_info, transition_to: :need_more_info
                        event :referee_requests_admin_approval, transition_to: :admin_approval
                        event :referee_rejects, transition_to: :might_need_review
                Severity: Major
                Found in app/models/concerns/approve_workflow.rb and 3 other locations - About 45 mins to fix
                app/models/concerns/approve_workflow.rb on lines 27..35
                app/models/concerns/approve_workflow.rb on lines 36..44
                app/models/concerns/approve_workflow.rb on lines 45..53

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

                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 4 locations. Consider refactoring.
                Open

                      state :undecided do
                        event :referee_approves, transition_to: :approved
                        event :referee_rejects, transition_to: :rejected
                        event :request_more_info, transition_to: :need_more_info
                        event :referee_requests_admin_approval, transition_to: :admin_approval
                Severity: Major
                Found in app/models/concerns/approve_workflow.rb and 3 other locations - About 45 mins to fix
                app/models/concerns/approve_workflow.rb on lines 7..15
                app/models/concerns/approve_workflow.rb on lines 27..35
                app/models/concerns/approve_workflow.rb on lines 45..53

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

                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 4 locations. Consider refactoring.
                Open

                      state :referee_approval do
                        event :referee_approves, transition_to: :approved
                        event :referee_rejects, transition_to: :undecided
                        event :request_more_info, transition_to: :need_more_info
                        event :referee_requests_admin_approval, transition_to: :admin_approval
                Severity: Major
                Found in app/models/concerns/approve_workflow.rb and 3 other locations - About 45 mins to fix
                app/models/concerns/approve_workflow.rb on lines 7..15
                app/models/concerns/approve_workflow.rb on lines 36..44
                app/models/concerns/approve_workflow.rb on lines 45..53

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

                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 4 locations. Consider refactoring.
                Open

                      state :might_need_review do
                        event :referee_approves, transition_to: :undecided
                        event :referee_rejects, transition_to: :rejected
                        event :request_more_info, transition_to: :need_more_info
                        event :referee_requests_admin_approval, transition_to: :admin_approval
                Severity: Major
                Found in app/models/concerns/approve_workflow.rb and 3 other locations - About 45 mins to fix
                app/models/concerns/approve_workflow.rb on lines 7..15
                app/models/concerns/approve_workflow.rb on lines 27..35
                app/models/concerns/approve_workflow.rb on lines 36..44

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

                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

                        def initialize(options = {})
                            @api_key = options[:api_key] || ENV['MAILCHIMP_API_KEY']
                            @list_id = options[:list_id] || ENV['MAILCHIMP_LIST_ID']
                            Rails.logger.info("MailchimpService::Client.initialize: #{@api_key}, #{list_id}")
                            @gibbon = Gibbon::Request.new(api_key: api_key, debug: true)
                Severity: Minor
                Found in app/models/mailchimp_service/client.rb and 1 other location - About 40 mins to fix
                app/models/mailchimp_service/client.rb on lines 16..20

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

                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

                        def setOptions(options = {})
                            @api_key = options[:api_key] || ENV['MAILCHIMP_API_KEY']
                            @list_id = options[:list_id] || ENV['MAILCHIMP_LIST_ID']
                            Rails.logger.info("MailchimpService::Client.setOptions: #{@api_key}, #{list_id}")
                            @gibbon = Gibbon::Request.new(api_key: api_key, debug: true)
                Severity: Minor
                Found in app/models/mailchimp_service/client.rb and 1 other location - About 40 mins to fix
                app/models/mailchimp_service/client.rb on lines 9..13

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

                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

                  reverse_geocoded_by :latitude, :longitude do |lab,results|
                    if geo = results.first
                      lab.city ||= geo.city
                      lab.county ||= geo.state
                      lab.postal_code ||= geo.postal_code
                Severity: Minor
                Found in app/models/lab.rb and 1 other location - About 35 mins to fix
                app/models/organization.rb on lines 86..93

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

                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

                  reverse_geocoded_by :latitude, :longitude do |org,results|
                    if geo = results.first
                      org.city ||= geo.city
                      org.county ||= geo.state
                      org.postal_code ||= geo.postal_code
                Severity: Minor
                Found in app/models/organization.rb and 1 other location - About 35 mins to fix
                app/models/lab.rb on lines 126..133

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

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

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

                    respond_with Project.joins(:collaborations).includes(:lab).references(:lab).collect { |p| {id: p.id, title: p.title, name: p.lab.name, latitude: p.lab.latitude, longitude: p.lab.longitude, kind: p.lab.kind}}
                Severity: Minor
                Found in app/controllers/api/v0/projects_controller.rb and 1 other location - About 35 mins to fix
                app/controllers/api/v2/projects_controller.rb on lines 15..15

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

                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

                Severity
                Category
                Status
                Source
                Language