gerard2p/koaton

View on GitHub

Showing 48 of 48 total issues

Function initializeORM has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function initializeORM (seed) {
let res = null;
/* istanbul ignore next */
schema.on('error', (err) => {
debug(err.stack);
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function loadSecurityContext has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function loadSecurityContext () {
AuthModel = models[inflector.pluralize(configuration.security.model)];
const Model = models[inflector.pluralize(configuration.security.model)];
/* istanbul ignore if */
if (!Model) {
Severity: Minor
Found in src/middleware/auth.js - About 1 hr to fix

Function nunjucks has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function nunjucks () {
const nunjucks = require(ProyPath('node_modules', 'nunjucks'));
const env = new nunjucks.Environment();
class Link {
constructor () {
Severity: Minor
Found in src/views/setup.js - About 1 hr to fix

Function manyToMany has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

manyToMany (configuration) {
let targetModel = inflector.pluralize(configuration.targetModel);
let intermediateTable = `${modelName}_${targetModel}`;
let key1 = `${modelName}ID`;
let key2 = `${targetModel}ID`;
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function makeLink has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function makeLink (ctx, url, render) {
let route = KoatonRouter.AllRoutes(ctx.subdomain).map(exp => {
let variables = (exp[1].match(/\$/g) || []).length;
let matches = (url.match(exp[0]) || []).length - 1;
if (matches === variables && url.replace(...exp).indexOf('.') === -1) {
Severity: Minor
Found in src/views/setup.js - About 1 hr to fix

Function subdomainrouter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default async function subdomainrouter (ctx, next) {
ctx.subdomain = 'www';
for (const subdomain of configuration.server.subdomains) {
if (ctx.request.host.indexOf(subdomain) === 0) {
ctx.state.subdomain = subdomain;
Severity: Minor
Found in src/middleware/subdomainrouter.js - About 1 hr to fix

Function getQuery has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function getQuery (database, model, filtergroup) {
let group = [];
for (let index in filtergroup) {
let filter = filtergroup[index];
if (filter.key.indexOf('.') > -1) {
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 1 hr to fix

Function token has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function token (ctx, next) {
await next();
ctx.state = {
data: {
client: await models.oauth2applications.findOne({
Severity: Minor
Found in src/middleware/oauth2server.js - About 1 hr to fix

Function request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

request (method, url, binding = 'index', secured = false) {
let Action;
if (typeof binding === 'boolean') {
secured = binding;
binding = 'index';
Severity: Minor
Found in src/support/KoatonRouter.js - About 1 hr to fix

Function start has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

App.start = function (port, usehttp2 = false) {
for (const route of koaton.router.options()) {
App.use(route);
}
let callback = () => {
Severity: Minor
Found in src/index.js - About 1 hr to fix

Function makerelation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makerelation (model, relation) {
let options = {
as: relation.As,
foreignKey: relation.key
};
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function getQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

async function getQuery (database, model, filtergroup) {
let group = [];
for (let index in filtergroup) {
let filter = filtergroup[index];
if (filter.key.indexOf('.') > -1) {
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 1 hr to fix

Function oauth2application has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

oauth2application (schema) {
return {
'model': {
'ClientId': {
type: schema.String
Severity: Minor
Found in src/middleware/oauth2models.js - About 1 hr to fix

Function prepareQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function prepareQuery (database, model, query, item) {
let [modelname, property] = item.split('.');
let prequery = {};
let value = (query.value ? query.value : query[item]);
value = query.condition === '===' ? value : (property === 'id' ? value : new RegExp(`.*${value}.*`));
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 1 hr to fix

Function constructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

constructor () {
/** @type {Object} */
this.bundles = null;
/** @type {Object} */
this.conections = null;
Severity: Minor
Found in src/support/configuration.js - About 1 hr to fix

Function oauth2accesstoken has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

oauth2accesstoken (schema) {
return {
'model': {
'UserId': {
type: schema.String
Severity: Minor
Found in src/middleware/oauth2models.js - About 1 hr to fix

Function rawWhere has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

model.rawWhere = function rawWhere (stringquery, opts) {
let that = this;
return new Promise(function (resolve, reject) {
let where = that.$where(stringquery);
for (let prop in opts) {
Severity: Minor
Found in src/support/extend_caminte.js - About 1 hr to fix

Function start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

App.start = function (port, usehttp2 = false) {
for (const route of koaton.router.options()) {
App.use(route);
}
let callback = () => {
Severity: Minor
Found in src/index.js - About 55 mins to fix

Function request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

request (method, url, binding = 'index', secured = false) {
let Action;
if (typeof binding === 'boolean') {
secured = binding;
binding = 'index';
Severity: Minor
Found in src/support/KoatonRouter.js - About 55 mins to fix

Avoid deeply nested control flow statements.
Open

if (!res[prop]) {
res[prop] = data[prop];
}
Severity: Major
Found in src/support/extend_caminte.js - About 45 mins to fix
Severity
Category
Status
Source
Language