GladysProject/Gladys

View on GitHub

Showing 742 of 2,674 total issues

Function waitForRestoreToFinish has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async waitForRestoreToFinish(state) {
      try {
        const restoreStatus = await state.httpClient.get('/api/v1/gateway/backup/restore/status');
        if (restoreStatus.restore_in_progress) {
          setTimeout(() => {
Severity: Minor
Found in front/src/actions/gateway.js - About 1 hr to fix

    Function connectBridge has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async connectBridge(state, bridge) {
        store.setState({
          philipsHueCreateDeviceStatus: RequestStatus.Getting
        });
        try {
    Severity: Minor
    Found in front/src/routes/integration/all/philips-hue/setup-page/actions.js - About 1 hr to fix

      Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render({}, { numberOfHoursBeforeStateIsOutdated }) {
          return (
            <div class="card">
              <h4 class="card-header">
                <Text id="systemSettings.numberOfHoursBeforeStateIsOutdated" />

        Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render(props, {}) {
            let temperature_min = this.props.box.temperature_min;
            let temperature_max = this.props.box.temperature_max;
        
            const unit = this.props.user.temperature_unit_preference;

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

          function newValueDuplexWirelessSwitch(message, data) {
            const { sid } = message;
            logger.debug(`Xiaomi : New value duplex wireless switch, sid = ${sid}`);
            const EXTERNAL_ID_CHANNEL_0_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-0:button`;
            const EXTERNAL_ID_CHANNEL_1_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-1:button`;

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

          async function scan() {
            if (!this.configured) {
              throw new ServiceNotConfiguredError();
            } else if (this.scanning) {
              logger.warn(`LANManager already scanning for devices...`);
          Severity: Minor
          Found in server/services/lan-manager/lib/lan-manager.scan.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 request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function request(url, dataCallback, authErrorCallback, errorCallback) {
            logger.debug(`Tasmota: HTTP looking for ${url}`);
            const req = http.get(url, (res) => {
              logger.debug(`Tasmota: HTTP response for ${url}: ${res.statusCode}`);
          
          
          Severity: Minor
          Found in server/services/tasmota/lib/http/tasmota.http.request.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 installMqttContainer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function installMqttContainer(config) {
            let dockerContainers = await this.gladys.system.getContainers({
              all: true,
              filters: { name: [containerDescriptor.name] },
            });
          Severity: Minor
          Found in server/services/zigbee2mqtt/lib/installMqttContainer.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 DIRECTIVE_NAMESPACES.BrightnessController has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            [DIRECTIVE_NAMESPACES.BrightnessController]: (
              directiveName,
              payload,
              currentValue,
              binaryCurrentValue,
          Severity: Minor
          Found in server/services/alexa/lib/deviceMappings.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 onNewCameraFile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function onNewCameraFile(
            cameraSelector,
            folderPath,
            cameraFolder,
            filename,
          Severity: Minor
          Found in server/services/rtsp-camera/lib/onNewCameraFile.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 installZ2mContainer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function installZ2mContainer(config) {
            const { z2mDriverPath } = config;
            let creationNeeded = false;
          
            let dockerContainers = await this.gladys.system.getContainers({
          Severity: Minor
          Found in server/services/zigbee2mqtt/lib/installZ2mContainer.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 poll has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function poll(device) {
            if (!this.connected) {
              await this.connect();
            }
          
          
          Severity: Minor
          Found in server/services/ewelink/lib/device/poll.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 setValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function setValue(device, deviceFeature, value) {
            const externalId = deviceFeature.external_id;
            const homeId = device.params.find((oneParam) => oneParam.name === PARAMS.HOME_ID);
            const roomId = device.params.find((oneParam) => oneParam.name === PARAMS.ROOM_ID);
            if (!homeId || !roomId) {
          Severity: Minor
          Found in server/services/netatmo/lib/netatmo.setValue.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 pollBinary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            pollBinary: (eWeLinkDevice, feature) => {
              const { deviceId, channel } = parseExternalId(feature.external_id);
              let state = (eWeLinkDevice.params && eWeLinkDevice.params.switch) || false;
              const switches = (eWeLinkDevice.params && eWeLinkDevice.params.switches) || false;
              if (state || switches) {
          Severity: Minor
          Found in server/services/ewelink/lib/features/binary.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 scan has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function scan(state, peripheralUuid = undefined) {
            if (!this.ready) {
              throw new Error('Bluetooth is not ready to scan for peripherals, check BLE adapter.');
            }
          
          
          Severity: Minor
          Found in server/services/bluetooth/lib/commands/bluetooth.scan.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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          async function create(message) {
            const gladysGatewayOpenAiEnabledVar = await this.variable.getValue(
              SYSTEM_VARIABLE_NAMES.GLADYS_GATEWAY_OPEN_AI_ENABLED,
            );
            const openAiEnabled = gladysGatewayOpenAiEnabledVar === 'true';
          Severity: Minor
          Found in server/lib/message/message.create.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 createActions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function createActions(store) {
            const actionsProfilePicture = createActionsProfilePicture(store);
          
            const actions = {
              async login(state, e) {
          Severity: Minor
          Found in front/src/actions/login/login.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 actions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          const actions = store => ({
            updateCalendarsToSync(state, e) {
              store.setState({
                calendarsToSync: {
                  ...state.calendarsToSync,
          Severity: Minor
          Found in front/src/routes/integration/all/caldav/sync-page/actions.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 createActions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function createActions(store) {
            const integrationActions = createActionsIntegration(store);
            const actions = {
              async getHouses(state) {
                store.setState({
          Severity: Minor
          Found in front/src/routes/integration/all/broadlink/device-page/actions.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 render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            render(props, {}) {
              let messageKey;
              let linkUrl = '';
              let linkText = '';
              if (!props.usbConfigured) {

          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