GladysProject/Gladys

View on GitHub

Showing 737 of 2,655 total issues

Function getCaldavSetting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async getCaldavSetting(state) {
    store.setState({
      caldavGetSettingsStatus: CalDAVStatus.Getting
    });

Severity: Minor
Found in front/src/routes/integration/all/caldav/share-page/actions.js - About 1 hr to fix

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

      render(props, {}) {
        return (
          <BaseEditBox {...props} titleKey="dashboard.boxTitle.clock">
            <div className="form-group">
              <label>
    Severity: Minor
    Found in front/src/components/boxs/clock/EditClock.jsx - About 1 hr to fix

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

        up: async (queryInterface, Sequelize) => {
          const service = await db.Service.findOne({
            where: {
              name: 'enedis',
            },
      Severity: Minor
      Found in server/migrations/20230414020652-enedis-unit-is-watt-hour.js - About 1 hr to fix

        Function cancelLearn has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function cancelLearn(peripheralIdentifier) {
          logger.debug(`Broalink leaving learn mode with ${peripheralIdentifier}`);
        
          clearTimeout(this.learnTimers[peripheralIdentifier]);
        
        
        Severity: Minor
        Found in server/services/broadlink/lib/learn/broadlink.cancelLearn.js - About 1 hr to fix

          Function connect has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function connect() {
            this.configured = false;
            this.connected = false;
          
            const email = await this.gladys.variable.getValue(EWELINK_EMAIL_KEY, this.serviceId);
          Severity: Minor
          Found in server/services/ewelink/lib/device/connect.js - About 1 hr to fix

            Function get has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function get(options) {
              const optionsWithDefault = { ...DEFAULT_OPTIONS, ...options };
              const include = [];
              if (optionsWithDefault.expand.includes('devices')) {
                include.push({
            Severity: Minor
            Found in server/lib/room/room.get.js - About 1 hr to fix

              Function init has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function init(startDeviceStateAggregate = true) {
                // load all devices in RAM
                const devices = await db.Device.findAll({
                  include: [
                    {
              Severity: Minor
              Found in server/lib/device/device.init.js - About 1 hr to fix

                Function deleteHouse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async deleteHouse(state, houseIndex) {
                      store.setState({
                        houseUpdateStatus: RequestStatus.Getting
                      });
                      const house = state.houses[houseIndex];
                Severity: Minor
                Found in front/src/actions/house.js - About 1 hr to fix

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

                  function createActions(store) {
                    const actions = {
                      async getUsers(state) {
                        store.setState({
                          usersGetStatus: RequestStatus.Getting
                  Severity: Minor
                  Found in front/src/actions/gatewayLinkUser.js - About 1 hr to fix

                    Function sendToUser has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function sendToUser(userSelector, text, file = null) {
                      const user = this.state.get('user', userSelector);
                      if (user === null) {
                        throw new NotFoundError(`User ${userSelector} not found`);
                      }
                    Severity: Minor
                    Found in server/lib/message/message.sendToUser.js - About 1 hr to fix

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

                        render(props, {}) {
                          return (
                            <SettingsLayout currentUrl={props.currentUrl}>
                              {props.newUser && (
                                <CreateUserPage
                      Severity: Minor
                      Found in front/src/routes/settings/settings-users/create-user/index.js - About 1 hr to fix

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

                          render(props, { loading, tooMuchStatesError, statesNumber }) {
                            return (
                              <div class="col-md-6">
                                <div class="card">
                                  <div class="card-header">{props.device.name || <Text id="integration.mqtt.device.noNameLabel" />}</div>
                        Severity: Minor
                        Found in front/src/routes/integration/all/philips-hue/device-page/Device.jsx - About 1 hr to fix

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

                            render(
                              props,
                              {
                                dashboards,
                                currentDashboard,
                          Severity: Minor
                          Found in front/src/routes/dashboard/edit-dashboard/index.js - About 1 hr to fix

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

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

                              Function updateFeatureProperty has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                updateFeatureProperty(e, property, featureIndex) {
                                  let value = e.target.value;
                                  let device;
                                  if (property === 'external_id' && !value.startsWith('mqtt:')) {
                                    if (value.length < 5) {
                              Severity: Minor
                              Found in front/src/routes/integration/all/mqtt/device-page/setup/index.js - About 1 hr to fix

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

                                function onExecute(body) {
                                  const directiveNamespace = get(body, 'directive.header.namespace');
                                  const directiveName = get(body, 'directive.header.name');
                                  const endpointId = get(body, 'directive.endpoint.endpointId');
                                  const correlationToken = get(body, 'directive.header.correlationToken');
                                Severity: Minor
                                Found in server/services/alexa/lib/alexa.onExecute.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 handleGladysMessage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function handleGladysMessage(topic, message) {
                                  const parsedTopic = topic.split('/');
                                  if (topic === 'gladys/master/device/create') {
                                    this.gladys.event.emit(EVENTS.DEVICE.NEW, JSON.parse(message));
                                  } else if (topic.startsWith('gladys/master/device/')) {
                                Severity: Minor
                                Found in server/services/mqtt/lib/handler/handleGladysMessage.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 throwErrorIfNeeded has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function throwErrorIfNeeded(response, emit = false, config = false) {
                                  if (response.error) {
                                    if (response.error === 406) {
                                      this.connected = false;
                                      this.accessToken = '';
                                Severity: Minor
                                Found in server/services/ewelink/lib/device/index.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 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

                                Severity
                                Category
                                Status
                                Source
                                Language