hicknhack-software/redmine_hourglass

View on GitHub

Showing 33 of 33 total issues

Method bulk has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def bulk(params_key = controller_name, &block)
      @bulk_success = []
      @bulk_errors = []
      entries = params[params_key]
      entries = entries.to_unsafe_h if Rails::VERSION::MAJOR >= 5 && entries.instance_of?(ActionController::Parameters)
Severity: Minor
Found in app/controllers/hourglass/api_base_controller.rb - About 2 hrs 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 chart_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def chart_data(chart_query)
      data = Hash.new([].freeze)
      ticks = []
      tooltips = Hash.new([].freeze)

Severity: Minor
Found in app/helpers/hourglass/chart_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 stop has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def stop
      stop = Time.now.change(sec: 0) + 1.minute
      time_log = nil
      transaction(requires_new: true) do
        if start < stop
Severity: Minor
Found in app/models/hourglass/time_tracker.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 update_query_from_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def update_query_from_params
    @query.project = params[:query_is_for_all] ? nil : @project
    @query.build_from_params(params)
    @query.column_names = nil if params[:default_columns]
    @query.sort_criteria = (params[:query] && params[:query][:sort_criteria]) || @query.sort_criteria
Severity: Minor
Found in app/controllers/hourglass_queries_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 split has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def split(args)
      split_at = args[:split_at].change(sec: 0)
      insert_new_before, round = args.values_at :insert_new_before, :round
      return if start >= split_at || split_at >= stop
      old_time = insert_new_before ? start : stop
Severity: Minor
Found in app/models/hourglass/time_log.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 bulk_create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def bulk_create
      bulk do |_, params|
        result = nil
        ActiveRecord::Base.transaction do
          result = Hourglass::TimeLog.create create_time_log_params params
Severity: Minor
Found in app/controllers/hourglass/time_bookings_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 sql_for_field has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)
Severity: Minor
Found in app/models/concerns/hourglass/query_base.rb - About 45 mins to fix

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

        def update_following_bookings(user, project_id, current_booking)
          booking = current_booking
          current_time_log = current_booking.time_log
          start = current_time_log.start
          loop do
    Severity: Minor
    Found in lib/hourglass/date_time_calculations.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 parse_assign_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_assign_params(new_settings = nil, options = nil, key = nil)
            key, options = [options, nil] if key == nil && options.is_a?(Symbol)
            new_settings = {"#{key}".to_sym => new_settings} if key.is_a?(Symbol)
            project = options[:project] if options.is_a? Hash
    
    
    Severity: Minor
    Found in lib/hourglass/settings_storage.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 stop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def stop
          time_tracker = authorize get_time_tracker
          time_log, time_booking = time_tracker.transaction do
            time_log = time_tracker.stop
            authorize time_log, :booking_allowed? if time_log && time_tracker.project
    Severity: Minor
    Found in app/controllers/hourglass/time_trackers_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_gaps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_gaps(bookings, start, stop)
          sorted = bookings.sort_by { |booking| booking.start }
          gaps = []
    
          unless sorted.first.start == start
    Severity: Minor
    Found in lib/hourglass/redmine_time_tracker_import.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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def join
          authorize Hourglass::TimeLog
          ids = params[:ids].uniq
          time_logs = Hourglass::TimeLog.where(id: ids).order start: :asc
          raise ActiveRecord::RecordNotFound if time_logs.length != ids.length
    Severity: Minor
    Found in app/controllers/hourglass/time_logs_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

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

        def available_columns
          @available_columns ||= self.class.available_columns.dup.tap do |available_columns|
            {
                time_entry: TimeEntryCustomField,
                issue: issue_custom_fields,
    Severity: Minor
    Found in app/models/hourglass/time_tracker_query.rb and 1 other location - About 40 mins to fix
    app/models/hourglass/time_booking_query.rb on lines 44..59

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

    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

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

        def available_columns
          @available_columns ||= self.class.available_columns.dup.tap do |available_columns|
            {
                time_entry: TimeEntryCustomField,
                issue: issue_custom_fields,
    Severity: Minor
    Found in app/models/hourglass/time_booking_query.rb and 1 other location - About 40 mins to fix
    app/models/hourglass/time_tracker_query.rb on lines 38..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 37.

    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
          time_log, time_booking = nil
          ActiveRecord::Base.transaction do
            time_log = Hourglass::TimeLog.create create_time_log_params
            raise ActiveRecord::Rollback unless time_log.persisted?
    Severity: Minor
    Found in app/controllers/hourglass/time_bookings_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 add_user_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_user_filter
        principals = []
        if project
          principals += project.principals.visible.sort
          unless project.leaf?
    Severity: Minor
    Found in app/models/concerns/hourglass/query_base.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 totals_sum has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def totals_sum(query)
          if query.grouped?
            query.totals_by_group.each_with_object(query.totalable_columns.map { |column| [column, 0.00] }.to_h) do |(_, totals), sum|
              transform_totals(totals).each do |column, total|
                sum[column] += total
    Severity: Minor
    Found in app/helpers/hourglass/list_helper.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def init
          now = Time.now.change sec: 0
          self.user ||= User.current
          previous_time_log = user.hourglass_time_logs.find_by(stop: now + 1.minute)
          self.project_id ||= issue && issue.project_id
    Severity: Minor
    Found in app/models/hourglass/time_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

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

        def change?(param = nil)
          condition = param ? protected_parameters.include?(param) : unsafe_attributes?
          if condition
            update_all_forbidden_message and return false unless authorized? :change_all
          end
    Severity: Minor
    Found in app/policies/hourglass/application_policy.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 booking_process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def booking_process(user, options)
          round = round?(options)
          if round
            previous_time_log = closest_booked_time_log user, options[:project_id], options[:start], after_current: false
            options[:start], options[:stop] = calculate_bookable_time options[:start], options[:stop], previous_time_log && previous_time_log.time_booking && previous_time_log.time_booking.rounding_carry_over, project: options[:project_id]
    Severity: Minor
    Found in lib/hourglass/date_time_calculations.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