GladysProject/Gladys

View on GitHub

Showing 742 of 2,674 total issues

Function command has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function command(message, classification, context) {
  let humidityResult;
  const roomEntity = classification.entities.find((entity) => entity.entity === 'room');
  try {
    switch (classification.intent) {
Severity: Minor
Found in server/lib/device/humidity-sensor/humidity-sensor.command.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 getEvents has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function getEvents(userId, options) {
  const where = {};

  if (options.from || options.to) {
    const oneWeekAgo = new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000);
Severity: Minor
Found in server/lib/calendar/calendar.getEvents.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 11 (exceeds 5 allowed). Consider refactoring.
Open

function createActions(store) {
  const houseActions = createActionsHouse(store);
  const integrationActions = createActionsIntegration(store);
  const actions = {
    async getXiaomiSensors(state) {
Severity: Minor
Found in front/src/routes/integration/all/xiaomi/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 11 (exceeds 5 allowed). Consider refactoring.
Open

function createActions(store) {
  const integrationActions = createActionsIntegration(store);
  const houseActions = createActionsHouse(store);
  const actions = {
    async getZigbee2mqttDevices(state, take, skip) {
Severity: Minor
Found in front/src/routes/integration/all/zigbee2mqtt/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 BaseEditBox has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const BaseEditBox = ({ children, ...props }) => {
  const { x, y } = props;
  const ref = useRef(null);
  const [{ isDragging }, drag, preview] = useDrag(() => ({
    type: DASHBOARD_EDIT_BOX_TYPE,
Severity: Minor
Found in front/src/components/boxs/baseEditBox.jsx - 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 AppRouter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

)(props => (
  <div id="app">
    <Layout currentUrl={props.currentUrl}>
      <Header
        currentUrl={props.currentUrl}
Severity: Minor
Found in front/src/components/app.jsx - 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 11 (exceeds 5 allowed). Consider refactoring.
Open

  render(props) {
    let alertMessage = null;

    const { connectMqttStatus, mqttConnected, mqttConnectionError } = props;
    switch (connectMqttStatus) {
Severity: Minor
Found in front/src/routes/integration/all/mqtt/setup-page/SetupTab.jsx - 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 EdfTempoService has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function EdfTempoService(gladys, serviceId) {
  const dayjs = require('dayjs');
  const axios = require('axios').default;
  const utc = require('dayjs/plugin/utc');
  const timezone = require('dayjs/plugin/timezone');
Severity: Minor
Found in server/services/edf-tempo/index.js - About 1 hr to fix

    Function convertFeature has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function convertFeature(tuyaFunctions, externalId) {
      const { code, values, name, readOnly } = tuyaFunctions;
    
      const featuresCategoryAndType = mappings[code];
      if (!featuresCategoryAndType) {
    Severity: Minor
    Found in server/services/tuya/lib/device/tuya.convertFeature.js - About 1 hr to fix

      Function poll has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function poll(device) {
        const externalId = device.external_id;
        const [prefix, topic] = device.external_id.split(':');
      
        if (prefix !== 'melcloud') {
      Severity: Minor
      Found in server/services/melcloud/lib/melcloud.poll.js - About 1 hr to fix

        Function onReportState has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function onReportState(body) {
          const deviceSelector = get(body, 'directive.endpoint.endpointId');
          const device = this.gladys.stateManager.get('device', deviceSelector);
          if (!device) {
            throw new NotFoundError(`Device "${deviceSelector}" not found`);
        Severity: Minor
        Found in server/services/alexa/lib/alexa.onReportState.js - About 1 hr to fix

          Function checkBatteries has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function checkBatteries() {
            const enabled = await this.variable.getValue(SYSTEM_VARIABLE_NAMES.DEVICE_BATTERY_LEVEL_WARNING_ENABLED);
            if (!enabled) {
              return;
            }
          Severity: Minor
          Found in server/lib/device/device.checkBatteries.js - About 1 hr to fix

            Function add has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function add(device) {
              this.stateManager.setState('device', device.selector, device);
              this.stateManager.setState('deviceByExternalId', device.external_id, device);
              this.stateManager.setState('deviceById', device.id, device);
              device.features.forEach((feature) => {
            Severity: Minor
            Found in server/lib/device/device.add.js - About 1 hr to fix

              Function login has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async login(state, e) {
                    if (e) {
                      e.preventDefault();
                    }
                    if (!validateEmail(state.loginFormEmailValue)) {
              Severity: Minor
              Found in front/src/actions/login/login.js - About 1 hr to fix

                Function componentWillMount has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async componentWillMount() {
                    let { deviceSelector } = this.props;
                    let device;
                
                    await Promise.all([this.props.getIntegrationByName(this.props.integrationName), this.props.getHouses()]);
                Severity: Minor
                Found in front/src/components/device/index.js - About 1 hr to fix

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

                    render(props) {
                      return (
                        <div class="row g-2 mb-2">
                          <div class="col-5">
                            <Localizer>
                  Severity: Minor
                  Found in front/src/routes/scene/edit-scene/actions/HttpRequest.jsx - About 1 hr to fix

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

                      render(props, { selectedDeviceFeaturesOptions, deviceOptions, loading, room }) {
                        const roomName = room && room.name;
                        return (
                          <BaseEditBox {...props} titleKey="dashboard.boxTitle.devices-in-room" titleValue={roomName}>
                            <div class={loading ? 'dimmer active' : 'dimmer'}>
                    Severity: Minor
                    Found in front/src/components/boxs/device-in-room/EditDeviceInRoom.jsx - About 1 hr to fix

                      Function createDevice has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const createDevice = (networkAddress, serviceId, username, password) => {
                        const externalId = `tasmota:${networkAddress}`;
                        const device = {
                          name: networkAddress,
                          external_id: externalId,
                      Severity: Minor
                      Found in server/services/tasmota/lib/http/tasmota.http.status.js - About 1 hr to fix

                        Function scanPresence has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function scanPresence() {
                          const devices = await this.gladys.device.get({
                            service: 'lan-manager',
                            device_feature_category: DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR,
                          });
                        Severity: Minor
                        Found in server/services/lan-manager/lib/lan-manager.scanPresence.js - About 1 hr to fix

                          Function up has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            up: async (queryInterface, Sequelize) => {
                              await queryInterface.createTable('t_device_feature_state', {
                                id: {
                                  allowNull: false,
                                  primaryKey: true,
                          Severity: Minor
                          Found in server/migrations/20190211041243-create-device-feature-state.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language