microfleet/core

View on GitHub

Showing 88 of 88 total issues

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

  return async function handler(request: Request) {
    const { headers } = request

    let parentSpan: SpanContext | null = null
    if (service.tracer !== undefined) {
Severity: Minor
Found in packages/plugin-router-hapi/src/adapter.ts - About 1 hr to fix

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

      private async checkEof(): Promise<void> {
        if (this.inDestroyingState() || !this.config.stopOnPartitionsEOF) {
          this.log?.debug('checkEof: destroying')
          return
        }
    Severity: Minor
    Found in packages/plugin-kafka/src/custom/consumer-stream.ts - About 1 hr to fix

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

      export default (config?: ValidateResponseConfig) => async function validateResponseHandler(
        this: Microfleet,
        request: ServiceRequest,
      ): Promise<void> {
        if (config === undefined) {
      Severity: Minor
      Found in packages/plugin-router/src/lifecycle/handlers/validate-response.ts - About 1 hr to fix

        Function attach has 26 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'))
        
          // load local schemas
          await this.validator.addLocation(resolve(__dirname, '../schemas'))
        Severity: Minor
        Found in packages/plugin-prometheus/src/prometheus.ts - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (uniqMessages.length != messages.length) {
                this.log?.warn({ uniqLength: uniqMessages.length, origLength: messages.length }, '[dup] Duplicates received')
              }
          Severity: Minor
          Found in packages/plugin-kafka/src/custom/consumer-stream.ts and 1 other location - About 55 mins to fix
          packages/plugin-kafka/src/custom/consumer-stream.ts on lines 341..343

          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 54.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (exceptPreviousOffset.length != uniqMessages.length) {
                this.log?.warn({ filtered: exceptPreviousOffset.length, uniqMessages: uniqMessages.length }, '[dup] Previous offset data received')
              }
          Severity: Minor
          Found in packages/plugin-kafka/src/custom/consumer-stream.ts and 1 other location - About 55 mins to fix
          packages/plugin-kafka/src/custom/consumer-stream.ts on lines 337..339

          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 54.

          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

          Further Reading

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

            private async initPlugins(config: ns.CoreOptions): Promise<void> {
              // require all modules
              const plugins: ns.Plugin[] = []
              for (const plugin of config.plugins) {
                const paths = isAbsolute(plugin)
          Severity: Minor
          Found in packages/core/src/index.ts - About 55 mins to fix

          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 handleIncomingMessages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            private handleIncomingMessages(messages: Message[]): void {
              const { unacknowledgedTracker, autoStore } = this
          
              if (!this.consumerDisconnected()) {
                this.consumer.pause(this.consumer.assignments())
          Severity: Minor
          Found in packages/plugin-kafka/src/custom/consumer-stream.ts - About 55 mins to fix

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                try {
                  await this.redis.quit()
                } catch (e: any) {
                  if (e.message === 'Connection is closed.') {
                    return
          Severity: Minor
          Found in packages/plugin-redis-sentinel/src/redis-sentinel.ts and 1 other location - About 50 mins to fix
          packages/plugin-redis-cluster/src/redis-cluster.ts on lines 118..126

          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 52.

          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

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          const toArray = <T>(x: T | T[]): T[] => Array.isArray(x) ? x : [x]
          Severity: Minor
          Found in packages/core/src/index.ts and 1 other location - About 50 mins to fix
          packages/plugin-router-amqp/src/plugin.ts on lines 25..25

          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 52.

          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

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                try {
                  await this.redis.quit()
                } catch (e: any) {
                  if (e.message === 'Connection is closed.') {
                    return
          Severity: Minor
          Found in packages/plugin-redis-cluster/src/redis-cluster.ts and 1 other location - About 50 mins to fix
          packages/plugin-redis-sentinel/src/redis-sentinel.ts on lines 108..116

          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 52.

          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

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          const toArray = <T>(x: T | T[]): T[] => Array.isArray(x) ? x : [x]
          Severity: Minor
          Found in packages/plugin-router-amqp/src/plugin.ts and 1 other location - About 50 mins to fix
          packages/core/src/index.ts on lines 33..33

          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 52.

          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

          Further Reading

          Function updatePartitionOffsets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private updatePartitionOffsets(partitions: Assignment[], map: CommitOffsetTracker): void {
              for (const topicPartition of partitions) {
                const trackingKey = KafkaConsumerStream.trackingKey(topicPartition)
          
                // if it has offset - verify that the current offset is smaller
          Severity: Minor
          Found in packages/plugin-kafka/src/custom/consumer-stream.ts - About 45 mins to fix

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          declare module '@microfleet/core-types' {
            interface Microfleet {
              redis: Redis.Redis;
              redisType: 'redisSentinel';
            }
          Severity: Minor
          Found in packages/plugin-redis-sentinel/src/redis-sentinel.ts and 1 other location - About 40 mins to fix
          packages/plugin-redis-cluster/src/redis-cluster.ts on lines 24..33

          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 49.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          declare module '@microfleet/core-types' {
            interface Microfleet {
              redis: Redis.Cluster;
              redisType: 'redisCluster';
            }
          Severity: Minor
          Found in packages/plugin-redis-cluster/src/redis-cluster.ts and 1 other location - About 40 mins to fix
          packages/plugin-redis-sentinel/src/redis-sentinel.ts on lines 21..30

          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 49.

          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

          Further Reading

          Function attach has a Cognitive Complexity of 7 (exceeds 5 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
          Severity: Minor
          Found in packages/plugin-redis-sentinel/src/redis-sentinel.ts - About 35 mins to fix

          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 tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            async tag({ annotation = this.options.tagAnnotation, args = this.options.tagArgs } = {}) {
              const context = this.config.getContext()
              const { stagedChanges } = context
              for (const stagedModule of stagedChanges.values()) {
                const message = format(annotation, { ...context, stagedModule })
          Severity: Minor
          Found in ci/pnpm-git.js - About 35 mins to fix

          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 topicExists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export function topicExists(data: TopicMetadata[], topics: SubscribeTopic | SubscribeTopicList): void {
            const topicList = Array.isArray(topics) ? topics : [topics]
            for (const topic of topicList) {
              const found = data.find((metaDataTopic) => {
                if (topic instanceof RegExp) return topic.test(metaDataTopic.name)
          Severity: Minor
          Found in packages/plugin-kafka/src/util.ts - About 35 mins to fix

          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 a Cognitive Complexity of 7 (exceeds 5 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()
          Severity: Minor
          Found in packages/plugin-redis-cluster/src/redis-cluster.ts - About 35 mins to fix

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            for (const prop of props) {
              if (!omitProps.includes(prop)) {
                action[prop] = input[prop]
              }
            }
          Severity: Minor
          Found in packages/plugin-router/src/utils.ts and 1 other location - About 30 mins to fix
          packages/plugin-router/src/utils.ts on lines 44..48

          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 45.

          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

          Further Reading

          Severity
          Category
          Status
          Source
          Language