Showing 26 of 80 total issues
File container.test.ts
has 821 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { throws } from 'smid'
import * as util from 'util'
import { createContainer, AwilixContainer } from '../container'
import { Lifetime } from '../lifetime'
import { AwilixResolutionError } from '../errors'
Function createContainerInternal
has 282 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createContainerInternal<
T extends object = any,
U extends object = any,
>(
options: ContainerOptions,
Function createTokenizer
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
export function createTokenizer(source: string) {
const end = source.length
let pos: number = 0
let type: TokenType = 'EOF'
let value: string = ''
- 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 createContainerInternal
has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring. Open
function createContainerInternal<
T extends object = any,
U extends object = any,
>(
options: ContainerOptions,
- 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 createTokenizer
has 157 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createTokenizer(source: string) {
const end = source.length
let pos: number = 0
let type: TokenType = 'EOF'
let value: string = ''
File load-modules.test.ts
has 420 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as path from 'path'
import { loadModules, LoadModulesOptions } from '../load-modules'
import { createContainer } from '../container'
import { Lifetime } from '../lifetime'
import { InjectionMode } from '../injection-mode'
File container.ts
has 372 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as util from 'util'
import {
AwilixRegistrationError,
AwilixResolutionError,
AwilixTypeError,
Function parseParameterList
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
export function parseParameterList(source: string): Array<Parameter> | null {
const { next: _next, done } = createTokenizer(source)
const params: Array<Parameter> = []
let t: Token = null!
- 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 resolve
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
function resolve(name: string | symbol, resolveOpts?: ResolveOptions): any {
resolveOpts = resolveOpts || {}
try {
// Grab the registration by name.
Function parseParameterList
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseParameterList(source: string): Array<Parameter> | null {
const { next: _next, done } = createTokenizer(source)
const params: Array<Parameter> = []
let t: Token = null!
File param-parser.test.ts
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { parseParameterList } from '../param-parser'
describe('parseParameterList', () => {
it('returns an empty array when invalid input is given', () => {
expect(parseParameterList('')).toEqual([])
File resolvers.ts
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { AwilixContainer, FunctionReturning, ResolveOptions } from './container'
import { AwilixTypeError } from './errors'
import { InjectionMode, InjectionModeType } from './injection-mode'
import { Lifetime, LifetimeType } from './lifetime'
import { Parameter, parseParameterList } from './param-parser'
Function advance
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function advance() {
value = ''
type = 'EOF'
// eslint-disable-next-line no-constant-condition
while (true) {
Function createInjectorProxy
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function createInjectorProxy<T extends object>(
container: AwilixContainer<T>,
injector: InjectorFunction,
) {
const locals = injector(container) as any
- 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 registerDescriptor
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function registerDescriptor<ESM extends boolean = false>(
container: AwilixContainer,
opts: LoadModulesOptions<ESM>,
moduleDescriptor: LoadedModuleDescriptor & { value: any },
) {
- 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 createInjectorProxy
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createInjectorProxy<T extends object>(
container: AwilixContainer<T>,
injector: InjectorFunction,
) {
const locals = injector(container) as any
Function generateResolve
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function generateResolve(fn: Function, dependencyParseTarget?: Function) {
// If the function used for dependency parsing is falsy, use the supplied function
if (!dependencyParseTarget) {
dependencyParseTarget = fn
}
- 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 parseLoadedModule
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseLoadedModule(
loaded: any,
m: ModuleDescriptor,
): Array<LoadedModuleDescriptor> {
const items: Array<LoadedModuleDescriptor> = []
Function registerDescriptor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function registerDescriptor<ESM extends boolean = false>(
container: AwilixContainer,
opts: LoadModulesOptions<ESM>,
moduleDescriptor: LoadedModuleDescriptor & { value: any },
) {
Function generateResolve
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateResolve(fn: Function, dependencyParseTarget?: Function) {
// If the function used for dependency parsing is falsy, use the supplied function
if (!dependencyParseTarget) {
dependencyParseTarget = fn
}