Showing 166 of 172 total issues
Similar blocks of code found in 6 locations. Consider refactoring. Open
constructor({ assertPresent, mongoAnalyzer, sequelizeAnalyzer, terminator }) {
assertPresent({
mongoAnalyzer,
sequelizeAnalyzer,
terminator,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 6 locations. Consider refactoring. Open
constructor({ assertPresent, mongodb, Sequelize, terminator }) {
assertPresent({
mongodb,
Sequelize,
terminator,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 6 locations. Consider refactoring. Open
constructor({ assertPresent, chalk, logger, Table }) {
assertPresent({
chalk,
logger,
Table,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
Function createAllReferences
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createAllReferences(databaseSchema, schemaGenerated) {
const references = {};
Object.keys(databaseSchema).forEach(tableName => {
references[tableName] = [];
});
Function MysqlTableConstraintsGetter
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MysqlTableConstraintsGetter(databaseConnection) {
const queryInterface = databaseConnection.getQueryInterface();
// NOTICE: provide an array of array. Each inner array representing a (possibly composite) unique
// index
Function runAuthenticated
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
async runAuthenticated() {
const parsed = await this.parse(DeleteCommand);
const config = { ...this.env, ...parsed.flags, ...parsed.args };
const manager = new EnvironmentManager(config);
Function connectToMongodb
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
connectToMongodb(options, isSSL) {
let connectionOptionsMongoClient = options.connectionOptions;
if (!connectionOptionsMongoClient) {
connectionOptionsMongoClient = {
useNewUrlParser: true,
- 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 constructor
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor({
assertPresent,
logger,
detectReferences,
applyReferences,
Function writeModel
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
writeModel(config, table, fields, references, options = {}) {
const { underscored } = options;
let modelPath = `models/${this.tableToFilename(table)}.js`;
if (config.appConfig.useMultiDatabase) {
modelPath = `models/${config.appConfig.modelsExportPath}/${this.tableToFilename(table)}.js`;
Function createFiles
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async createFiles(config, schema) {
const { isUpdate, useMultiDatabase, modelsExportPath } = config.appConfig;
await this.mkdirp(`${this.projectPath}/routes`);
await this.mkdirp(`${this.projectPath}/forest`);
Identical blocks of code found in 2 locations. Consider refactoring. Open
const detectReference = (databaseConnection, field, collectionName) =>
pickSampleValues(databaseConnection, collectionName, field)
.then(samples => findCollectionMatchingSamples(databaseConnection, samples))
.then(matches => filterReferenceCollection(matches))
.then(referencedCollection => buildReference(collectionName, referencedCollection, field));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
const detectReference = (databaseConnection, field, collectionName) =>
pickSampleValues(databaseConnection, collectionName, field)
.then(samples => findCollectionMatchingSamples(databaseConnection, samples))
.then(matches => filterReferenceCollection(matches))
.then(referencedCollection => buildReference(collectionName, referencedCollection, field));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function runAuthenticated
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async runAuthenticated() {
const parsed = await this.parse(ResetCommand);
const envSecret = this.env.FOREST_ENV_SECRET;
const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
let config;
Function analyzeMongoCollections
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async analyzeMongoCollections(databaseConnection) {
const collections = await databaseConnection.collections();
if (collections.length === 0) {
this.restoreDefaultState();
throw new EmptyDatabaseError('no collections found', {
Function mapCollection
has 42 lines of code (exceeds 25 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) {
Function createProject
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.createProject = async (config, sessionToken, project) => {
let newProject;
try {
newProject = await agent
Function createReference
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function createReference(
tableName,
existingsReferences,
association,
foreignKey,
- 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"