Showing 11 of 13 total issues
Function execute
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async execute(version: number, rerun?: boolean): Promise<void> {
const control = await this.getControl(); // Side effect: upserts control document.
let currentVersion = control.version;
// Run the actual migration
File Migration.ts
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
// tslint:disable:variable-name
import { EDirection, IMigration, IMigrationOptions } from '@underbase/types';
import { logger } from '@underbase/utils';
import chalk from 'chalk';
import _ from 'lodash';
Function execute
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private async execute(version: number, rerun?: boolean): Promise<void> {
const control = await this.getControl(); // Side effect: upserts control document.
let currentVersion = control.version;
// Run the actual migration
- 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 checkMigrationPaths
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
const checkMigrationPaths = async (config: IConfigFile, versions: string[]) => {
let success = true;
const migrations = await getMigrationsEntryFiles(config, versions);
for (const path of migrations) {
- 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 checkMigrationPaths
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const checkMigrationPaths = async (config: IConfigFile, versions: string[]) => {
let success = true;
const migrations = await getMigrationsEntryFiles(config, versions);
for (const path of migrations) {
Function migrate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const migrate = async (
direction: EDirection,
idx: number,
): Promise<void> => {
if (!this._db) {
Function migrateTo
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async migrateTo(command: string | number): Promise<void> {
if (!this._db) {
throw new Error(
'Migration instance has not be configured/initialized.' +
' Call <instance>.config(..) to initialize this instance',
Function config
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async config(opts?: IMigrationOptions): Promise<void> {
this.options = Object.assign({}, this.options, opts);
if (this.options.logger === null && this.options.logs === true) {
this.options.logger = logger;
Function action
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const action: TCommandAction = async ({ config, versions, argv }) => {
if (config.supportFile && fs.existsSync(path.resolve(config.supportFile))) {
try {
const support = await import(path.resolve(config.supportFile));
- 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 migrateTo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public async migrateTo(command: string | number): Promise<void> {
if (!this._db) {
throw new Error(
'Migration instance has not be configured/initialized.' +
' Call <instance>.config(..) to initialize this instance',
- 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 config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public async config(opts?: IMigrationOptions): Promise<void> {
this.options = Object.assign({}, this.options, opts);
if (this.options.logger === null && this.options.logs === true) {
this.options.logger = logger;
- 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"