GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

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

  render(props, { houseOptions, selectedHouseOption }) {
    return (
      <div>
        <p>
          {props.action.type === ACTIONS.HOUSE.IS_EMPTY && (

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

      async getConfiguration() {
        let melCloudUsername = '';
        let melCloudPassword = '';
    
        this.setState({
    Severity: Minor
    Found in front/src/routes/integration/all/melcloud/setup-page/SetupTab.jsx - About 1 hr to fix

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

      async function poll(device) {
        const { lightId, bridgeSerialNumber } = parseExternalId(device.external_id);
        const hueApi = this.hueApisBySerialNumber.get(bridgeSerialNumber);
        if (!hueApi) {
          throw new NotFoundError(`HUE_API_NOT_FOUND`);
      Severity: Minor
      Found in server/services/philips-hue/lib/light/light.poll.js - 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 configureBridge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function configureBridge(ipAddress) {
        const bridge = this.bridgesByIP.get(ipAddress);
        if (!bridge) {
          logger.info(`Connecting to hue bridge ip = ${ipAddress} manually (not from discovered bridges)...`);
        } else {
      Severity: Minor
      Found in server/services/philips-hue/lib/light/light.configureBridge.js - 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 rgbToHsb has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function rgbToHsb(rgb, maxSB = 100) {
        let r = rgb[0];
        let g = rgb[1];
        let b = rgb[2];
        r /= 255;
      Severity: Minor
      Found in server/utils/colors.js - 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 buildUrl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildUrl(device, command = undefined) {
        const [, networkAddress] = device.external_id.split(':');
        const url = new URL(`http://${networkAddress}`);
      
        if (device && device.params) {
      Severity: Minor
      Found in server/services/tasmota/lib/http/tasmota.http.request.js - 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 getAccessToken has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function getAccessToken(refreshToken, scope) {
        if (!refreshToken || refreshToken.length === 0) {
          throw new BadParameters();
        }
        const refreshTokenHash = hashRefreshToken(refreshToken);
      Severity: Minor
      Found in server/lib/session/session.getAccessToken.js - 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 installContainer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function installContainer(config) {
        if (!(await this.isEnabled())) {
          logger.info('Nodered: is not enabled, skipping...');
          return;
        }
      Severity: Minor
      Found in server/services/node-red/lib/installContainer.js - 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 saveConfiguration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function saveConfiguration({ mqttUrl, mqttUsername, mqttPassword, useEmbeddedBroker }) {
        const { variable } = this.gladys;
        const oldUser = await variable.getValue(CONFIGURATION.MQTT_USERNAME_KEY, this.serviceId);
        await updateOrDestroyVariable(variable, CONFIGURATION.MQTT_EMBEDDED_BROKER_KEY, useEmbeddedBroker, this.serviceId);
        await updateOrDestroyVariable(variable, CONFIGURATION.MQTT_URL_KEY, mqttUrl, this.serviceId);
      Severity: Minor
      Found in server/services/mqtt/lib/saveConfiguration.js - 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 setValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function setValue(broadlinkDevice, gladysDevice, deviceFeature, value) {
        const { type } = deviceFeature;
        const valueStr = value.toString();
      
        // Check for valued code
      Severity: Minor
      Found in server/services/broadlink/lib/commands/features/broadlink.remote.js - 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 saveZ2mBackup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function saveZ2mBackup(payload) {
        logger.info('Zigbee2mqtt: storing backup...');
      
        const { jobId, resolve: jobResolver, reject: jobRejecter } = this.backupJob;
        if (jobId) {
      Severity: Minor
      Found in server/services/zigbee2mqtt/lib/saveZ2mBackup.js - 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 forwardMessageToOpenAI has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function forwardMessageToOpenAI({ message, previousQuestions, context }) {
        try {
          const response = await this.openAIAsk({
            question: message.text,
            previous_questions: previousQuestions,
      Severity: Minor
      Found in server/lib/gateway/gateway.forwardMessageToOpenAI.js - 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 executeAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function executeAction(self, action, scope, columnIndex, rowIndex) {
        if (!actionsFunc[action.type]) {
          throw new Error(`Action type "${action.type}" does not exist.`);
        }
      
      
      Severity: Minor
      Found in server/lib/scene/scene.executeActions.js - 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 command has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function command(message, classification, context) {
        const cameraImages = [];
      
        const roomEntity = classification.entities.find((entity) => entity.entity === 'room');
        const deviceEntity = classification.entities.find((entity) => entity.entity === 'device');
      Severity: Minor
      Found in server/lib/device/camera/camera.command.js - 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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function get(userId, options = {}) {
        const where = {};
      
        // if we ask specifically for shared calendar
        // only returned shared calendars
      Severity: Minor
      Found in server/lib/calendar/calendar.get.js - 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 notify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      async function notify(device, event) {
        logger.debug(`Notify device ${device.selector} creation`);
      
        const serviceFuncName = FUNC_BY_EVENT[event];
      
      
      Severity: Minor
      Found in server/lib/device/device.notify.js - 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        render(props, {}) {
          const boxData = get(props, `${DASHBOARD_BOX_DATA_KEY}Weather.${props.x}_${props.y}`);
          const boxStatus = get(props, `${DASHBOARD_BOX_STATUS_KEY}Weather.${props.x}_${props.y}`);
          const weatherObject = get(boxData, 'weather');
          const displayMode = this.props.box.modes || {};
      Severity: Minor
      Found in front/src/components/boxs/weather/WeatherBox.jsx - 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 updateValue has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          async updateValue(state, device, deviceFeature, roomIndex, deviceIndex, deviceFeatureIndex, value) {
      Severity: Major
      Found in front/src/actions/device.js - About 50 mins to fix

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

        async function setValue(gladysDevice, gladysFeature, value) {
          if (!gladysFeature.external_id.startsWith('zwavejs-ui:')) {
            throw new BadParameters(
              `ZWaveJs-UI deviceFeature external_id is invalid: "${gladysFeature.external_id}" should starts with "zwavejs-ui:"`,
            );
        Severity: Minor
        Found in server/services/zwavejs-ui/lib/zwaveJSUI.setValue.js - 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

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

        module.exports = function UserController(gladys) {
          /**
           * @api {post} /api/v1/user Create
           * @apiName CreateUser
           * @apiGroup User
        Severity: Minor
        Found in server/api/controllers/user.controller.js - 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

        Severity
        Category
        Status
        Source
        Language