GSA/jobs_api

View on GitHub
app/models/position_opening.rb

Summary

Maintainability
F
3 days
Test Coverage

Method search_for has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
Open

    def search_for(options = {})
      options.reverse_merge!(size: 10, from: 0)
      document_limit = [options[:size].to_i, MAX_RETURNED_DOCUMENTS].min
      source = options[:source]
      sort_by = options[:sort_by] || :timestamp
Severity: Minor
Found in app/models/position_opening.rb - About 1 day 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 search_for has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def search_for(options = {})
      options.reverse_merge!(size: 10, from: 0)
      document_limit = [options[:size].to_i, MAX_RETURNED_DOCUMENTS].min
      source = options[:source]
      sort_by = options[:sort_by] || :timestamp
Severity: Major
Found in app/models/position_opening.rb - About 5 hrs to fix

    File position_opening.rb has 346 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'active_model'
    require 'elasticsearch/dsl'
    
    class PositionOpening
      include ActiveModel::Model
    Severity: Minor
    Found in app/models/position_opening.rb - About 4 hrs to fix

      Method delete_expired_docs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def delete_expired_docs
            query = Elasticsearch::DSL::Search.search do
              query do
                bool do
                  filter do
      Severity: Minor
      Found in app/models/position_opening.rb - About 1 hr to fix

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

            def import(position_openings)
              position_openings.each do |opening|
                data = opening.each_with_object(timestamp: DateTime.current) do |(key, value), d|
                  d[key] =
                    case key
        Severity: Minor
        Found in app/models/position_opening.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status