GSA/code-gov-adapters

View on GitHub

Showing 6 of 23 total issues

File utils.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('lodash');
const Bodybuilder = require('bodybuilder');
const { getConfig } = require('./config');
const moment = require('moment');
const DATE_FORMAT = 'YYYY-MM-DD';
Severity: Minor
Found in libs/elasticsearch/utils.js - About 5 hrs to fix

Function getConfig has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getConfig() {
  const filterMappings = {
    "nested": {
      "license": {
        "path": "permissions.licenses",
Severity: Major
Found in libs/elasticsearch/config/index.js - About 2 hrs to fix

Function getFlattenedMappingPropertiesByType has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function getFlattenedMappingPropertiesByType(mapping) {
  let props = {};

  const _recurseMappingTree = (mappingTree, pathArr) => {
    if (mappingTree["properties"]) {
Severity: Minor
Found in libs/elasticsearch/utils.js - 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

Function _addIncludeExclude has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function _addIncludeExclude ({ body, queryParams }) {
  let include = queryParams.include || null;
  let exclude = queryParams.exclude || null;
  let _source = {};
  const _enforceArray = (obj) => {
Severity: Minor
Found in libs/elasticsearch/utils.js - 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

Function omitPrivateKeys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function omitPrivateKeys (collection) {
  const omitFn = (value) => {
    if (value && typeof value === 'object') {
      Object.keys(value).forEach((key) => {
        if (key[0] === '_') {
Severity: Minor
Found in libs/elasticsearch/utils.js - 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

Function _addRangeFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function _addRangeFilter ({ body, field, lteRange, gteRange }) {
  let ranges = {};

  if(lteRange) {
    try {
Severity: Minor
Found in libs/elasticsearch/utils.js - 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