OpenHPS/openhps-mqtt

View on GitHub

Showing 5 of 13 total issues

Function _onMessage has 124 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private _onMessage(topic: string, payload: Buffer): void {
        const topicParts = topic.replace(this.options.prefix , '').split('/');
        const type = topicParts[0];
        const uid = topicParts[1];
        const action = topicParts[2];
Severity: Major
Found in src/client/service/MQTTClient.ts - About 4 hrs to fix

    Function _onInitServer has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private _onInitServer(): Promise<void> {
            return new Promise((resolve, reject) => {
                const brokerId = `BROKER_${process.pid}_${Math.random().toString(16).substring(2, 8)}`;
                this.aedes = (aedes as any)({
                    id: brokerId,
    Severity: Major
    Found in src/server/service/MQTTServer.ts - About 2 hrs to fix

      File MQTTClient.ts has 262 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { DataFrame, DataSerializer, Node, PullOptions, PushOptions, RemoteService, Service } from '@openhps/core';
      import { Client, connect } from 'mqtt';
      import { MQTTSinkNode, MQTTSourceNode } from '../nodes';
      import { MQTTClientOptions } from './MQTTClientOptions';
      
      
      Severity: Minor
      Found in src/client/service/MQTTClient.ts - About 2 hrs to fix

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

        const bundle = (env, module) => ({
          name: PROJECT_NAME,
          entry: `./dist/${module ? "esm" : "cjs"}/client/index.js`,
          output: {
            path: path.resolve(__dirname, 'dist'),
        Severity: Minor
        Found in webpack.config.js - About 1 hr 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 _onMessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private _onMessage(topic: string, payload: Buffer): void {
                const topicParts = topic.replace(this.options.prefix , '').split('/');
                const type = topicParts[0];
                const uid = topicParts[1];
                const action = topicParts[2];
        Severity: Minor
        Found in src/client/service/MQTTClient.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

        Severity
        Category
        Status
        Source
        Language