Showing 11 of 217 total issues
File document_search_spec.rb
has 942 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
describe DocumentSearch do
let(:query) { 'common' }
let(:handles) { %w[agency_blogs] }
Method build_search_query
has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring. Open
def build_search_query
doc_query = self
search.query do
function_score do
- Read upRead up
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
File documents_spec.rb
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
require 'uri'
describe Api::V1::Documents do
let(:id) { 'some really!weird@id.name' }
File collections_spec.rb
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
describe Api::V1::Collections do
let(:valid_session) do
env_secrets = Rails.application.config_for(:secrets)
Class Documents
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Documents
include Templatable
LIGHT_STEMMERS = {
de: 'german',
es: 'spanish',
Method build_search_query
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_search_query
doc_query = self
search.query do
function_score do
File document_query.rb
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
class DocumentQuery
include Elasticsearch::DSL
HIGHLIGHT_OPTIONS = {
pre_tags: ["\ue000"],
Class DocumentQuery
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class DocumentQuery
include Elasticsearch::DSL
HIGHLIGHT_OPTIONS = {
pre_tags: ["\ue000"],
Method extract_hits
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def extract_hits(hits)
hits.map do |hit|
highlight = hit['highlight']
source = deserialized(hit)
if highlight.present?
- Read upRead up
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 linguistic_filter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def linguistic_filter(json, locale, lines, name, field, type)
Method search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def search
i14y_search_results = execute_client_search
if i14y_search_results.total.zero? && i14y_search_results.suggestion.present?
suggestion = i14y_search_results.suggestion
doc_query.query = suggestion['text']
- Read upRead up
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"