Showing 6 of 20 total issues
Function formatValidationErrors
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
function formatValidationErrors(ajvErrors) {
const normalizedErrors = {};
for (let i = 0; i < ajvErrors.length; ++i) {
const err = ajvErrors[i];
- 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 formatValidationErrors
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function formatValidationErrors(ajvErrors) {
const normalizedErrors = {};
for (let i = 0; i < ajvErrors.length; ++i) {
const err = ajvErrors[i];
Function getManyByIds
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getManyByIds(ids) {
return new Promise((resolve, reject) => {
User.findAll({
attributes: PUBLIC_API_ATTRIBUTES,
where: {
Function startServer
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function startServer() {
initDbLogger(log);
database.sync()
.then(() => {
Function value
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const value = ((keyword) => {
switch (keyword) {
case 'required':
return 'cannot be blank';
case 'minLength':
Function validateUniqueConstraints
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function validateUniqueConstraints(error) {
if (error.name === 'SequelizeUniqueConstraintError') {
const errorInfo = {};
if (error.fields.vanity_name) {
- 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"