Showing 24 of 436 total issues
Function getInstances
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
export function getInstances(
options: SyncpackConfig,
wrappers: SourceWrapper[],
): Instances {
const allInstances: Instances = {
- 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 getConfig
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getConfig = (
disk: Disk,
program: Partial<SyncpackConfig & { configPath: string | undefined }>,
): SyncpackConfig => {
type OptionName = keyof SyncpackConfig;
Function getConfig
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
export const getConfig = (
disk: Disk,
program: Partial<SyncpackConfig & { configPath: string | undefined }>,
): SyncpackConfig => {
type OptionName = keyof SyncpackConfig;
- 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 getInstances
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getInstances(
options: SyncpackConfig,
wrappers: SourceWrapper[],
): Instances {
const allInstances: Instances = {
File get-input.spec.ts
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
import 'expect-more-jest';
import { join } from 'path';
import { getInput } from '.';
import { mockDisk } from '../../../test/mock-disk';
import { CWD, DEFAULT_CONFIG } from '../../constants';
Function createScenario
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createScenario(
fileMocks: {
path: string;
before: SourceWrapper;
after: SourceWrapper;
Function listMismatches
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function listMismatches(input: ProgramInput, disk: Disk): void {
let isInvalid = false;
/**
* Reverse the list so the default/ungrouped version group is rendered first
Function fixMismatches
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fixMismatches(input: ProgramInput, disk: Disk): void {
/**
* Reverse the list so the default/ungrouped version group is rendered first
* (appears at the top). The actual version groups which the user configured
* will then start from index 1.
Function format
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function format(input: ProgramInput, disk: Disk): void {
const { indent, sortAz, sortFirst, wrappers } = input;
wrappers.forEach(({ contents, filePath, json }) => {
const sortedKeys = Object.keys(contents).sort();
Function dependentDoesNotMatchNestedWorkspaceVersion
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
dependentDoesNotMatchNestedWorkspaceVersion() {
return createScenario(
[
{
path: 'workspaces/a/packages/a/package.json',
Function semverRangesDoNotMatchConfig
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
semverRangesDoNotMatchConfig() {
return createScenario(
[
{
path: 'packages/a/package.json',
Function list
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function list(input: ProgramInput, disk: Disk): void {
let isInvalid = false;
/**
* Reverse the list so the default/ungrouped version group is rendered first
Function getRangeScore
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function getRangeScore(version: string): number {
if (version === '') return 0;
if (version === RANGE_ANY) return 8;
const range = getRange(version);
if (range === RANGE_GT) return 7;
- 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 mockedFiles
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const mockedFiles: MockedFile[] = fileMocks.map((file) => {
const absolutePath = join(CWD, file.path);
const relativePath = normalize(file.path);
return {
absolutePath,
Function mockPackage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const mockPackage = (
dirName: string,
{
deps,
devDeps,
- 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
Avoid too many return
statements within this function. Open
if (range === RANGE_MINOR) return 5;
Avoid too many return
statements within this function. Open
if (range === RANGE_LTE) return 1;
Avoid too many return
statements within this function. Open
return raw;
Avoid too many return
statements within this function. Open
return rawHighest;
Avoid too many return
statements within this function. Open
if (range === RANGE_LT) return 0;