robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

Method get_balanced_term_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def get_balanced_term_data(user, section=Osm::Section.get(user.osm_api, section_id))
    zones = {:number => {}, :time => {}}
    methods = {:number => {}, :time => {}}

    meetings = Osm::Meeting.get_for_section(user.osm_api, section_id, term_id, {:no_cache => true})
Severity: Minor
Found in app/models/programme_review_balanced_cache.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 become has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def become
    user = User.find(params[:id])
    if user
      current_user = user
      session[:user_id] = user.id
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 configuration= has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def configuration=(config)
    conversion_functions = {
      :integer => Proc.new { |value| value.to_i },
      :positive_integer => Proc.new { |value| value.to_i.magnitude },
      :boolean => Proc.new { |value| ['0', 0].include?(value) ? false : !!value },
Severity: Minor
Found in app/models/automation_task.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 get_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def get_list
    emails = Array.new
    no_emails = Array.new
    section = Osm::Section.get(user.osm_api, section_id)
    fail Osm::Forbidden if section.nil?
Severity: Minor
Found in app/models/email_list.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 configuration= has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def configuration=(config)
    conversion_functions = {
      :integer => Proc.new { |value| value.to_i },
      :positive_integer => Proc.new { |value| value.to_i.magnitude },
      :boolean => Proc.new { |value| value.is_a?(String) ? value.eql?('1') : !!value },
Severity: Minor
Found in app/models/email_reminder_item.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 get_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def get_data
    earliest = configuration[:the_last_n_weeks].weeks.ago.to_date
    latest = Date.current

    api = user.osm_api
Severity: Minor
Found in app/models/email_reminder_item_not_seen.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 seconds_to_time has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def seconds_to_time(seconds)
    fail ArgumentError 'time must be a positive number' if !seconds.is_a?(Numeric) || seconds < 0

    parts = []
    remaining = seconds
Severity: Minor
Found in app/helpers/application_helper.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 get_data has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_data
    latest = configuration[:the_next_n_weeks].weeks.from_now.to_date
    earliest = Date.current

    api = user.osm_api
Severity: Minor
Found in app/models/email_reminder_item_advised_absence.rb - About 1 hr to fix

    Method sections has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.sections
        section_ids_seen = []
        section_types = {:beavers=>0, :cubs=>0, :scouts=>0, :explorers=>0, :adults=>0, :waiting=>0}
        subscription_levels = {1=>0, 2=>0, 3=>0}
        addons = {'Badges'=>0, 'Events'=>0, 'Payments'=>0, 'Programme'=>0, 'GoCardless'=>0}
    Severity: Minor
    Found in app/models/statistics.rb - About 1 hr to fix

      Method create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          user = login(params[:email_address].downcase, params[:password])
          Rails.logger.debug "SessionsController#create: user is #{user.inspect}"
      
          if user
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 1 hr to fix

        Method get_balanced_statistics has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def get_balanced_statistics(data, type)
            statistics = {}
        
            [:number, :time].each do |num_or_time|
              statistics[num_or_time] = {
        Severity: Minor
        Found in app/models/programme_review.rb - About 1 hr to fix

          Method leader_access_audit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def leader_access_audit
              unless @my_params[:sections].is_a?(Hash)
                flash[:error] = 'You must select some sections to sudit'
                redirect_to reports_path
                return
          Severity: Minor
          Found in app/controllers/reports_controller.rb - About 1 hr to fix

            Method no_current_term has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def no_current_term(email_list, exception)
                @email_list = email_list
                user = @email_list.user
            
                unless user.nil? || !user.connected_to_osm? || @email_list.section_id.nil?
            Severity: Minor
            Found in app/mailers/email_list_mailer.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 no_current_term has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def no_current_term(reminder, exception)
                @reminder = reminder
                user = reminder.user
            
                unless user.nil? || !user.connected_to_osm? || @reminder.section_id.nil?
            Severity: Minor
            Found in app/mailers/email_reminder_mailer.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 similar? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def similar?(a, b)
                if a.is_a? Array
                  a.each do |item|
                    return true if similar?(item, b)
                  end
            Severity: Minor
            Found in app/models/programme_review_balanced_cache.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 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @user = User.new(params[:user].permit(:name, :email_address, :password, :password_confirmation, :gdpr_consent))
                @user.gdpr_consent ||= false
            
                if @signup_code
            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 no_current_term has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def no_current_term(task, exception)
                @task = task
                user = task.user
            
                unless user.nil? || !user.connected_to_osm? || task.section_id.nil?
            Severity: Minor
            Found in app/mailers/automation_task_mailer.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 perform has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def perform
                noterm_emails_sent = {}
                forbidden_emails_sent = {}
                tasks = AutomationTask.where(active: true).order(:section_id)
                count = tasks.count
            Severity: Minor
            Found in app/jobs/automation_tasks_job.rb - About 1 hr to fix

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

                  unless user.nil? || !user.connected_to_osm? || @reminder.section_id.nil?
                    api = user.osm_api
                    @next_term = nil
                    @last_term = nil
                    terms = Osm::Term.get_for_section(api, @email_list.section)
              Severity: Major
              Found in app/mailers/email_reminder_mailer.rb and 1 other location - About 1 hr to fix
              app/mailers/email_list_mailer.rb on lines 20..29

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

              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

                  unless user.nil? || !user.connected_to_osm? || @email_list.section_id.nil?
                    api = user.osm_api
                    @next_term = nil
                    @last_term = nil
                    terms = Osm::Term.get_for_section(api, @email_list.section)
              Severity: Major
              Found in app/mailers/email_list_mailer.rb and 1 other location - About 1 hr to fix
              app/mailers/email_reminder_mailer.rb on lines 57..66

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

              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