Showing 91 of 172 total issues
Function TableConstraintsGetter
has 292 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TableConstraintsGetter(databaseConnection, schema) {
const queryInterface = databaseConnection.getQueryInterface();
this.perform = async table => {
let query = null;
Function perform
has 289 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.perform = async table => {
let query = null;
const replacements = { table };
switch (queryInterface.sequelize.options.dialect) {
Function Authenticator
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
function Authenticator({
logger,
api,
chalk,
inquirer,
- 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
File sequelize-tables-analyzer.js
has 443 lines of code (exceeds 250 allowed). Consider refactoring. Open
const { inject } = require('@forestadmin/context');
const P = require('bluebird');
const { plural, singular } = require('pluralize');
const ColumnTypeGetter = require('./sequelize-column-type-getter');
const DefaultValueExpression = require('./sequelize-default-value');
Function ColumnTypeGetter
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ColumnTypeGetter(databaseConnection, schema, allowWarning = true) {
const queryInterface = databaseConnection.getQueryInterface();
function isDialect(dialect) {
return queryInterface.sequelize.options.dialect === dialect;
Function mapCollection
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
function mapCollection(keys = this, emitFunction, store) {
// this block is to inject the emit function when this code is running locally
var emitAction;
if (emitFunction && store) {
emitAction = function emit(key, value) {
- 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
File agent-nodejs.ts
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { Config, DbConfig } from '../../interfaces/project-create-interface';
import type { Language } from '../../utils/languages';
import type Strings from '../../utils/strings';
import type Lodash from 'lodash';
File forest-express.js
has 327 lines of code (exceeds 250 allowed). Consider refactoring. Open
const { URL } = require('url');
const { plural, singular } = require('pluralize');
const IncompatibleLianaForUpdateError = require('../../errors/dumper/incompatible-liana-for-update-error');
const InvalidForestCLIProjectStructureError = require('../../errors/dumper/invalid-forest-cli-project-structure-error');
const AbstractDumper = require('./abstract-dumper').default;
Function EnvironmentManager
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
function EnvironmentManager(config) {
const { assertPresent, authenticator, env, keyGenerator } = Context.inject();
assertPresent({ authenticator, env, keyGenerator });
this.listEnvironments = async () => {
File mongo-collections-analyzer.js
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
const P = require('bluebird');
const { ObjectId } = require('mongodb');
const EmptyDatabaseError = require('../../../../errors/database/empty-database-error');
Function SchemaSerializer
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SchemaSerializer() {
// WARNING: Attributes declaration order is important for .forestadmin-schema.json format.
const options = {
id: 'name',
// TODO: Remove nameOld attribute once the lianas versions older than 2.0.0 are minority.
Function Api
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
function Api({
pkg,
env,
superagent: agent,
applicationTokenSerializer,
- 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 ApimapSorter
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ApimapSorter(apimap) {
const { assertPresent, logger, lodash } = inject();
assertPresent({ logger, lodash });
function sortArrayOfObjects(array) {
File sequelize-table-constraints-getter.js
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
const MysqlTableConstraintsGetter = require('./mysql-table-constraints-getter');
function TableConstraintsGetter(databaseConnection, schema) {
const queryInterface = databaseConnection.getQueryInterface();
Function analyzeSequelizeTables
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function analyzeSequelizeTables(connection, config, allowWarning) {
const { assertPresent, lodash } = inject();
assertPresent({ lodash });
// User provided a schema, check if it exists
Function perform
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.perform = async (columnInfo, columnName, tableName) => {
const { logger } = Context.inject();
const { type } = columnInfo;
switch (type) {
Function JobStateChecker
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function JobStateChecker(message, oclifExit) {
const { assertPresent, authenticator, env, logger } = Context.inject();
assertPresent({ authenticator, env, logger });
const bar = new ProgressBar(`${message} [:bar] :percent `, { total: 100 });
- 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
ForestExpress
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class ForestExpress extends AbstractDumper {
templateFolder = 'forest-express';
constructor(context) {
super(context);
Function readSchema
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
readSchema() {
this.logger.log('Reading ".forestadmin-schema.json" from current directory...');
const filename = '.forestadmin-schema.json';
if (!this.fs.existsSync(filename)) {
Function ProjectManager
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ProjectManager(config) {
const { assertPresent, authenticator, env, jwtDecode, lodash } = Context.inject();
assertPresent({ authenticator, env, jwtDecode, lodash });
function deserialize(response) {