Showing 88 of 88 total issues
Function performMigration
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function performMigration(redis: Redis.Redis | Redis.Cluster, service: Microfleet, scripts: unknown): Promise<boolean> {
let files: Migration[]
if (typeof scripts === 'string') {
debug('looking for files in %s', scripts)
files = await glob('*{.js,/}', { cwd: scripts, withFileTypes: true })
Function getAMQPRouterAdapter
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getAMQPRouterAdapter(
service: Microfleet,
config: RouterAMQPPluginConfig,
onComplete?: (this: Microfleet, err: Error | null | undefined, data: any, actionName: string, raw: Message) => Promise<any>
): MessageConsumer {
Function attach
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(
this: Microfleet,
opts: Partial<Config> = {}
): Promise<PluginInterface> {
assert(this.hasPlugin('logger'), new NotFoundError('logger module must be included'))
Function attachConsulPlugin
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export const attach = async function attachConsulPlugin(
this: Microfleet,
opts: Partial<ConsulConfig> = {}
): Promise<PluginInterface> {
assert(this.hasPlugin('logger'), new NotFoundError('log module must be included'))
- 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 attach
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(
this: Microfleet,
opts: ValidatorConfig,
parentFile: string
): Promise<void> {
Function auditLogFactory
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function auditLogFactory(params: AuditLogExtensionParams = {}): LifecycleExtensions {
const { getErrorLevel } = params
const disableLogErrorsForNames: string[] = params.disableLogErrorsForNames || []
return [
Function attach
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(
this: Microfleet,
options: Partial<RouterPluginConfig>
): Promise<PluginInterface> {
assert(this.hasPlugin('logger'), 'log module must be included')
Function attach
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(this: Microfleet, opts: Partial<Config> = {}): Promise<PluginInterface> {
assert(this.hasPlugin('validator'), new NotFoundError('validator module must be included'))
await this.validator.addLocation(resolve(__dirname, '../schemas'))
const bird = Bluebird.getNewLibraryCopy()
Function readLoop
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private async readLoop(): Promise<void> {
while (!this.consumerDisconnected() && !this.endEmitted) {
// when consumer disconnecting it throws Error: KafkaConsumer is not connected
const bufferAvailable = this.readableHighWaterMark - this.readableLength
const fetchSize = this.config.streamAsBatch ? this.fetchSize : bufferAvailable
- 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 responseHandler
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export default async function responseHandler(this: Microfleet, request: ServiceRequest): Promise<void> {
const { error, reformatError } = request
if (error !== undefined) {
if (reformatError === 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 attach
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(this: Microfleet, opts: Partial<Config> = {}): Promise<PluginInterface> {
assert(this.hasPlugin('validator'), new NotFoundError('validator module must be included'))
await this.validator.addLocation(resolve(__dirname, '../schemas'))
// @ts-expect-error - promise not defined, but can be used
Function responseHandler
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function responseHandler(this: Microfleet, request: ServiceRequest): Promise<void> {
const { error, reformatError } = request
if (error !== undefined) {
if (reformatError === true) {
Function attach
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function attach(
this: Microfleet,
options: Partial<AMQPPluginConfig> = {}
): Promise<PluginInterface> {
assert(this.hasPlugin('logger'), new NotFoundError('log module must be included'))
Function initPlugin
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public async initPlugin<T extends Record<string, unknown>>(mod: ns.Plugin<T>, conf?: any): Promise<void> {
const pluginName = mod.name
debug('initializing', pluginName)
let expose: ns.PluginInterface
- 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 commitMessages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public async commitMessages(messages: Message[]): Promise<void> {
const offsets: TopicPartitionOffset[] = messages.map(m => ({
topic: m.topic,
partition: m.partition,
offset: m.offset + 1,
- 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 getMigrationFile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const getMigrationFile = async (script: Path) => {
let file = script.fullpath()
if (script.isDirectory()) {
const files = await script.readdir()
- 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 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(consumer: KafkaConsumer, config: ConsumerStreamOptions, log?: Logger) {
assert(consumer.isConnected(), 'consumer should be connected')
assert(consumer instanceof KafkaConsumer, 'should be intance of KafkaConsumer')
const fetchSize = config.fetchSize || 1
const highWaterMark = config.streamAsBatch ? 1 : fetchSize
Function initPlugin
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async initPlugin<T extends Record<string, unknown>>(mod: ns.Plugin<T>, conf?: any): Promise<void> {
const pluginName = mod.name
debug('initializing', pluginName)
let expose: ns.PluginInterface
Function factory
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function factory(this: Microfleet, Cassandra: Cassandra, config: Config) {
const { models } = config.service
const reconnectOpts = {
interval: 500,
backoff: 2,
Function handler
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async handler(this: Microfleet, request: ServiceRequest) {
const { requestStarted, error, response } = request
const requestEnded = request.requestEnded = process.hrtime()
const meta: MetaLog = {