GladysProject/Gladys

View on GitHub

Showing 737 of 2,655 total issues

Function startStreaming has 181 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function startStreaming(cameraSelector, isGladysGateway, segmentDuration = 1) {
  // If stream already exist, return existing stream
  if (this.liveStreams.has(cameraSelector)) {
    const liveStream = this.liveStreams.get(cameraSelector);
    // If we are in a local stream, and new request come from Gladys Plus
Severity: Major
Found in server/services/rtsp-camera/lib/startStreaming.js - About 7 hrs to fix

    Function createActions has 177 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createActions(store) {
      const integrationActions = createActionsIntegration(store);
      const actions = {
        async getTasmotaDevices(state) {
          store.setState({
    Severity: Major
    Found in front/src/routes/integration/all/tasmota/actions.js - About 7 hrs to fix

      File Chart.jsx has 460 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Component } from 'preact';
      import { connect } from 'unistore/preact';
      import cx from 'classnames';
      
      import { Text } from 'preact-i18n';
      Severity: Minor
      Found in front/src/components/boxs/chart/Chart.jsx - About 7 hrs to fix

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

          render(
            { housesWithRooms = [], broadlinkPeripherals = [], ...props },
            { device, selectedFeature, selectedValue, editedFeatures = {}, learning, learnAllMode, peripheral, saveStatus }
          ) {
            const canSave = Object.keys(editedFeatures).length === 0 || !device.name;

          File gateway.js has 452 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import get from 'get-value';
          import update from 'immutability-helper';
          import { route } from 'preact-router';
          import { RequestStatus, LoginStatus } from '../utils/consts';
          import { validateEmail } from '../utils/validator';
          Severity: Minor
          Found in front/src/actions/gateway.js - About 6 hrs to fix

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

              render({ feature, featureIndex, canEditCategory, device, ...props }) {
                const allowModifyCategory =
                  canEditCategory && canEditCategory(device, feature) && DEVICE_FEATURE_COMPATIBLE_CATEGORY[feature.type];
            
                return (
            Severity: Major
            Found in front/src/components/device/UpdateDeviceFeature.jsx - About 6 hrs to fix

              Function exports has 160 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = (sequelize, DataTypes) => {
                const User = sequelize.define(
                  't_user',
                  {
                    id: {
              Severity: Major
              Found in server/models/user.js - About 6 hrs to fix

                Function buildService has 154 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function buildService(device, features, categoryMapping) {
                  const { Characteristic, CharacteristicEventTypes, Perms, Service } = this.hap;
                
                  const service = new Service[categoryMapping.service](device.name);
                
                
                Severity: Major
                Found in server/services/homekit/lib/buildService.js - About 6 hrs to fix

                  Function createActions has 153 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function createActions(store) {
                    const actions = {
                      async ping(state) {
                        store.setState({
                          PingStatus: RequestStatus.Getting
                  Severity: Major
                  Found in front/src/actions/system.js - About 6 hrs to fix

                    File RemoteCreation.jsx has 417 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import { Component, Fragment } from 'preact';
                    import { Text, Localizer } from 'preact-i18n';
                    import { Link } from 'preact-router/match';
                    import update from 'immutability-helper';
                    import get from 'get-value';

                      Function Header has 146 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const Header = ({ ...props }) => {
                        if (isUrlInArray(props.currentUrl, PAGES_WITHOUT_HEADER)) {
                          return null;
                        }
                        // Adapt forum URL to user language
                      Severity: Major
                      Found in front/src/components/header/index.jsx - About 5 hrs to fix

                        File SetupTab.jsx has 406 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { Component } from 'preact';
                        import { Text, MarkupText, Localizer } from 'preact-i18n';
                        import { RequestStatus } from '../../../../../utils/consts';
                        import CheckStatus from './CheckStatus.js';
                        import classNames from 'classnames/bind';
                        Severity: Minor
                        Found in front/src/routes/integration/all/node-red/setup-page/SetupTab.jsx - About 5 hrs to fix

                          Function newValueVibration has 142 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function newValueVibration(message, data) {
                            const { sid } = message;
                            logger.debug(`Xiaomi : New value vibration, sid = ${sid}`);
                            const newSensor = {
                              service_id: this.serviceId,
                          Severity: Major
                          Found in server/services/xiaomi/lib/event/xiaomi.newValueVibration.js - About 5 hrs to fix

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

                              render(props) {
                                return (
                                  <div>
                                    {props.philipsHueBridgesDevices && props.philipsHueBridgesDevices.length > 0 && (
                                      <div class="card">
                            Severity: Major
                            Found in front/src/routes/integration/all/philips-hue/setup-page/SetupTab.jsx - About 5 hrs to fix

                              File NetatmoDeviceBox.jsx has 403 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import { Component } from 'preact';
                              import { Text, Localizer, MarkupText } from 'preact-i18n';
                              import cx from 'classnames';
                              import { connect } from 'unistore/preact';
                              import dayjs from 'dayjs';
                              Severity: Minor
                              Found in front/src/routes/integration/all/netatmo/NetatmoDeviceBox.jsx - About 5 hrs to fix

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

                                  render(props, state, { loading }) {
                                    return (
                                      <div class="card">
                                        <div class="card-header">
                                          <h1 class="card-title">
                                Severity: Major
                                Found in front/src/routes/integration/all/netatmo/setup-page/SetupTab.jsx - About 5 hrs to fix

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

                                    render(
                                      { deviceIndex, device, housesWithRooms, editable, ...props },
                                      { loading, errorMessage, tooMuchStatesError, statesNumber }
                                    ) {
                                      const validModel = device.features && device.features.length > 0;
                                  Severity: Major
                                  Found in front/src/routes/integration/all/ewelink/EweLinkDeviceBox.jsx - About 5 hrs to fix

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

                                      render(props, { loading, saveError, testConnectionError, testConnectionErrorMessage }) {
                                        return (
                                          <div class="col-lg-6">
                                            <div class="card">
                                              <div
                                    Severity: Major
                                    Found in front/src/routes/integration/all/rtsp-camera/RtspCameraBox.jsx - About 5 hrs to fix

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

                                        render(props, { selectedDeviceFeaturesOptions, deviceOptions, loading, displayPreview }) {
                                          return (
                                            <BaseEditBox {...props} titleKey="dashboard.boxTitle.chart" titleValue={props.box.title}>
                                              <div class={loading ? 'dimmer active' : 'dimmer'}>
                                                <div class="loader" />
                                      Severity: Major
                                      Found in front/src/components/boxs/chart/EditChart.jsx - About 5 hrs to fix

                                        Function createActions has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        function createActions(store) {
                                          const actions = {
                                            async getHouses(state) {
                                              store.setState({
                                                housesGetStatus: RequestStatus.Getting
                                        Severity: Minor
                                        Found in front/src/actions/house.js - About 5 hrs 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