moser/foxtrot_mike

View on GitHub

Showing 69 of 90 total issues

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

  def to_csv
    CSV.generate(encoding: 'UTF-8', col_sep: "\t") do |csv|
      csv << headers
      @flights.each do |flight|
        csv << [flight.id,
Severity: Minor
Found in app/models/flight_exporter.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_accounting_entries has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def create_accounting_entries
    accounting_entries_without_validity_check.destroy_all
    if cost
      sum = cost.free_sum
      abstract_flight.liabilities_with_default.map do |l|
Severity: Minor
Found in lib/launch_accounting_entries.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 format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.format(minutes)
    if minutes.nil?
      ""
    elsif minutes >= 0
      h, m = [minutes / 60, minutes % 60]
Severity: Minor
Found in app/models/day_time.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

Function date has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  date: function(str) {
    matches = this.date_pattern_de.exec(str);
    if(matches != null && matches.length == 4) {
      obj = {m: this.integer(matches[2]), d: this.integer(matches[1]), y: this.integer(matches[3]) };
    } else {
Severity: Minor
Found in app/assets/javascripts/app.js - 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
    @account = Account.find(params[:account_id]) if params[:account_id]
    @account ||= current_account
    @own = @account == current_account
    authorize! :update, @account unless @own
Severity: Minor
Found in app/controllers/passwords_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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @person_cost_categories = PersonCostCategory.all
    @plane_cost_categories = PlaneCostCategory.all
    @wire_launcher_cost_categories = WireLauncherCostCategory.all

Severity: Minor
Found in app/controllers/cost_rules_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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @obj = parent
    authorize! :destroy, @obj
    redirect_to "/403.html" if AccountingEntry === @obj && !@obj.manual?
    if @obj.destroy
Severity: Minor
Found in app/controllers/destroy_confirmations_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

            elsif l =~ /([0-9]*) examples*, 0 failures/
              `notify-send --hint=int:transient:1 '#{$1} example#{$1 == "1" ? "" : "s"} passed' -i ~/code/foxtrot_mike/.notify-img/passed.png &> /dev/null`
              notified = true
              if @run_all_when_green && ((DateTime.now - @last_time_all) * 1440) > 5 #only run all after green every 5 minutes
                #@run_all = true 
Severity: Major
Found in autospec.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  if @run_all_when_green 
                    #@run_all = true 
                    @run_all_when_green = false
                  end
    Severity: Major
    Found in autospec.rb - About 45 mins to fix

      Function insert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        insert: function(h, target, link) {
          h.find('a.inline_form_hide').bind('click', function(e) {
            target.show();
            h.remove();
            return false;
      Severity: Minor
      Found in app/assets/javascripts/inline_form.js - 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 generate_filtered_flights_path has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def generate_filtered_flights_path(obj, from, to, group_by, aggregate_entries, format = :html)
      Severity: Minor
      Found in app/helpers/filtered_flights_helper.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      `notify-send --hint=int:transient:1 '#{$1} example#{$1 == "1" ? "" : "s"}, #{$2} pending' -i ~/code/foxtrot_mike/.notify-img/pending.png &> /dev/null`
        Severity: Major
        Found in autospec.rb - About 45 mins to fix

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

            def create
              if types.include?(params[:cost_rule_condition_type])
                p params[:cost_rule_condition][params[:cost_rule_condition_type].underscore]
                @cost_rule_condition = params[:cost_rule_condition_type].constantize.new(params[:cost_rule_condition][params[:cost_rule_condition_type].underscore])
                authorize! :create, @cost_rule_condition
          Severity: Minor
          Found in app/controllers/cost_rule_conditions_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 distance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def distance(str2)
              str1 = self.downcase
              str2 = str2.downcase
              if $KCODE =~ /^U/i
                unpack_rule = 'U*'
          Severity: Minor
          Found in lib/core_ext.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 included has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.included(base)
              base.extend ClassMethods
              base.validates_presence_of :valid_from
              base.validates_each :valid_to do |record, attr, value|
                unless record.valid_from.nil? || record.valid_to.nil? || record.valid_from < record.valid_to
          Severity: Minor
          Found in lib/validity_check.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              if params[:person_cost_category_id] && params["#{other_cost_category}_id"]
                model_all(:person_cost_category_id => params[:person_cost_category_id],
                          "#{other_cost_category}_id" => params["#{other_cost_category}_id"])
              else
          Severity: Minor
          Found in app/controllers/abstract_cost_rules_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 matches? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def matches?(flight, conditions = nil)
              unless conditions
                valid_at?(flight.departure_date) && flight_type == flight.class.to_s && matches?(flight, [ person_cost_category, plane_cost_category, cost_rule_conditions ].flatten)
              else
                conditions.empty? || (conditions[0].matches?(flight) && matches?(flight, conditions[1..-1]))
          Severity: Minor
          Found in app/models/flight_cost_rule.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 upsert_financial_accounts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def upsert_financial_accounts(file)
            unmatched = []
            CSV.foreach(file, headers: true) do |line|
              account = FinancialAccount.where(name: line['name']).first
              if account
          Severity: Minor
          Found in csv_upsert.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 build_mtimes_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def build_mtimes_hash(globs, first)
            files = @files || {}
            globs.each { |g|
              Dir[g].each { |file| files[file] = first ? File.mtime(file) : (files[file] || (Time.now - 86400)) }
            }
          Severity: Minor
          Found in autospec.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 flights has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def flights
              if @model_class && @id
                filter_by = @model_class.singularize.camelcase
                raise ActiveRecord::RecordNotFound.new unless %w(Airfield License Group Plane Person).include?(filter_by)
                filter_by.constantize.find(@id).flights
          Severity: Minor
          Found in app/models/affiliation_flight_filter.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