Showing 38 of 38 total issues
Function lookup
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
lookup<T>(specifier: string, options: { raw?: true, loose?: boolean } = {}): T | false {
// Raw lookups skip caching and singleton behavior
if (options.raw) {
let entry = this.lookupRaw<T>(specifier);
if (entry === false && !options.loose) {
Function respond
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async respond({ params }: any) {
let error = params.error;
assert(error, 'Error action must be invoked with an error as a param');
// Print the error to the logs
if ((!error.status || error.status >= 500) && this.config.environment !== 'test') {
- 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 ContainerEntryNotFound
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
ContainerEntryNotFound(specifier: string, registryEntries: string[], resolverNames: string[]) {
let registrationsOverview;
if (registryEntries.length > 0) {
registrationsOverview = dedent`
Available manual registrations (via container.register(...)):
Function parse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async parse(request: Request) {
let body = await this.bufferAndParseBody(request);
let result: ResponderParams = {
query: request.query,
Function startServer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected startServer(argv: any, project: Project) {
let bootstrapPath = project.isAddon ? path.join('test/dummy/index.js') : 'index.js';
let args = [ bootstrapPath ];
if (argv.debugBrk) {
args.unshift('--inspect-brk');
Function handle
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async handle(req: IncomingMessage, res: ServerResponse): Promise<void> {
let serverConfig = this.config.get('server');
let request = new Request(req, serverConfig);
try {
Function request
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async request(options: { method: string, url: string, body?: any, headers?: { [key: string]: string } }): Promise<{ status: number, body: any }> {
let body: any = null;
options.headers = mapKeys(options.headers, (value, key) => key.toLowerCase()) || {};
if (options.body) {
body = typeof options.body === 'string' ? options.body : JSON.stringify(options.body);
Function render
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async render(status: number, body?: any, options?: RenderOptions): Promise<void> {
if (typeof status !== 'number') {
options = body;
body = status;
status = 200;
- 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 handle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async handle(req: IncomingMessage, res: ServerResponse): Promise<void> {
let serverConfig = this.config.get('server');
let request = new Request(req, serverConfig);
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 run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async run(request: Request, response: ServerResponse) {
this.request = request;
this.response = response;
// Parse the incoming request based on the action's chosen parser
Function parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async parse(request: Request) {
let body = await this.bufferAndParseBody(request);
let result: ResponderParams = {
query: request.query,
- 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 protocol
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
get protocol(): 'http' | 'https' {
let rawProtocol: 'http' | 'https' = (<TLSSocket>this.incomingMessage.connection).encrypted ? 'https' : 'http';
let ip = this.incomingMessage.connection.remoteAddress;
let trustProxyConfig = this.config.trustProxy || constant(false);
- 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 run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async run(argv: any) {
let knex = tryRequire('knex');
if (!knex) {
await spinner.start('Installing knex (required for migrations)');
let yarnExists = await commandExists('yarn');
- 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 serializeRelationship
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected async serializeRelationship(relationship: string, config: RelationshipConfig, descriptor: RelationshipDescriptor, model: Model, action: Action, options: RenderOptions) {
let relatedSerializer = lookup<JSONSerializer>(`serializer:${ descriptor.relatedModelName }`, { loose: true }) || lookup<JSONSerializer>(`serializer:application`, { loose: true });
if (typeof relatedSerializer === 'boolean') {
throw new Error(`No serializer found for ${ descriptor.relatedModelName }, and no fallback application serializer found either`);
}
- 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 false;
Function hostname
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
get hostname(): string {
let host = this.getHeader('X-Forwarded-Host');
let ip = this.incomingMessage.socket.remoteAddress;
let trustProxyConfig = this.config.trustProxy || constant(false);
- 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 installAddon
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async installAddon(addonName: string) {
debug(`attempting to install ${ addonName }`);
// Find the package info first to confirm it exists and is a denali addon
let pkgManager = await commandExists('yarn') ? 'yarn' : 'npm';
debug(`package manager is: ${ pkgManager }`);
- 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 runTests
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected runTests(files: string[], project: Project, outputDir: string, argv: any) {
let avaPath = path.join(process.cwd(), 'node_modules', '.bin', 'ava');
files = files.map((pattern) => path.join(outputDir, pattern));
let args = files.concat([ '--concurrency', argv.concurrency ]);
if (argv.debug) {
- 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"