Showing 9 of 28 total issues
Function parseArgs
has 151 lines of code (exceeds 30 allowed). Consider refactoring. Open
export async function parseArgs(argv: Array<string>): Promise<ParseResults> {
let mode: MODE = MODE.check;
const parser = yargs(argv)
.usage('Usage: salty-dog <mode> [options]')
Function main
has 66 lines of code (exceeds 30 allowed). Consider refactoring. Open
export async function main(argv: Array<string>): Promise<number> {
const { args, mode } = await parseArgs(argv.slice(ARGS_START));
if (mode === MODE.complete) {
yargs(argv).showCompletionScript();
return STATUS_SUCCESS;
Function printTable
has 38 lines of code (exceeds 30 allowed). Consider refactoring. Open
export function printTable<T>(rows: Array<T>, fields: Array<keyof T>, options: TableOptions): string {
const cols = new Map<keyof T, Array<string>>();
// add headers
for (const field of fields) {
Function listFiles
has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring. Open
export async function listFiles(path: string): Promise<Array<string>> {
const dirs: Array<string> = [path];
const files: Array<string> = [];
while (dirs.length > 0) {
- 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 printTable
has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring. Open
export function printTable<T>(rows: Array<T>, fields: Array<keyof T>, options: TableOptions): string {
const cols = new Map<keyof T, Array<string>>();
// add headers
for (const field of fields) {
- 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 loadRuleModules
has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring. Open
export async function loadRuleModules(modules: Array<string>, ctx: VisitorContext, load?: LoadBack): Promise<Array<Rule>> {
const rules = [];
for (const name of modules) {
try {
- 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 main
has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring. Open
export async function main(argv: Array<string>): Promise<number> {
const { args, mode } = await parseArgs(argv.slice(ARGS_START));
if (mode === MODE.complete) {
yargs(argv).showCompletionScript();
return STATUS_SUCCESS;
- 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
return Math.min(ctx.errors.length, STATUS_MAX);
Avoid too many return
statements within this function. Open
return STATUS_ERROR;