Function aggsSubQuery
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
function aggsSubQuery(keys, aggsSearchQuery, queryFilters, contextFilters, customQueries) {
let aggs = {};
for (const key of keys) {
const keyWithoutKeyword = key.replace(".keyword", "");
let filter = unsafeStrucuredClone({ bool: { must: [], filter: contextFilters } });
- 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
Function buildMissionContext
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function buildMissionContext(user) {
const contextFilters = [];
// A young can only see validated missions.
if (isYoung(user)) contextFilters.push({ term: { "status.keyword": "VALIDATED" } });
- 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
Function aggsSubQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
function aggsSubQuery(keys, aggsSearchQuery, queryFilters, contextFilters, customQueries) {
Function buildApplicationContext
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function buildApplicationContext(user) {
const contextFilters = [];
if (!canSearchInElasticSearch(user, "application")) return { applicationContextError: { status: 403, body: { ok: false, code: ERRORS.OPERATION_UNAUTHORIZED } } };
- 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
Function buildRequestBody
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
function buildRequestBody({ searchFields, filterFields, queryFilters, page, sort, contextFilters, customQueries, size = 10 }) {
// We always need a fresh query to avoid side effects.
const getMainQuery = () => unsafeStrucuredClone({ bool: { must: [{ match_all: {} }], filter: contextFilters } });
// Search query
const search = (queryFilters.searchbar || []).filter((e) => e.trim()).length ? searchSubQuery(queryFilters.searchbar, searchFields) : null;
- 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"