GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

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

module.exports = function VariableController(gladys) {
  /**
   * @api {post} /api/service/:service_name/variable/:variable_key Save service variable
   * @apiName SaveVariable
   * @apiGroup Variable
Severity: Minor
Found in server/api/controllers/variable.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

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

async function poll(userId) {
  const bot = this.bots[userId];
  let result = {};
  let interval = 50;

Severity: Minor
Found in server/services/nextcloud-talk/lib/bot/bot.poll.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 onNewCameraFile has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  cameraSelector,
  folderPath,
  cameraFolder,
  filename,
  sharedObjectToVerify,
Severity: Minor
Found in server/services/rtsp-camera/lib/onNewCameraFile.js - About 45 mins to fix

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

    async function retrieveTokens(body) {
      logger.debug('Getting tokens to Netatmo API...');
      const { clientId, clientSecret, scopes } = this.configuration;
      const { codeOAuth, state, redirectUri } = body;
      if (!clientId || !clientSecret || !codeOAuth) {
    Severity: Minor
    Found in server/services/netatmo/lib/netatmo.retrieveTokens.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 configureContainer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    async function configureContainer(config) {
      logger.info('Node-RED: Docker container is being configured...');
    
      const { basePathOnContainer } = await this.gladys.system.getGladysBasePath();
    
    
    Severity: Minor
    Found in server/services/node-red/lib/configureContainer.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 buildFeatures has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function buildFeatures(deviceName, expose, parentType) {
      const { type, name, property, access, value_min: minValue, value_max: maxValue, unit: deviceUnit, values } = expose;
      const { names = {}, feature, getFeatureIndexes = () => [''] } = exposesMap[type] || {};
      const byName = buildByName(names, name, parentType);
    
    
    Severity: Minor
    Found in server/services/zigbee2mqtt/utils/features/buildFeatures.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 stopStreaming has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    async function stopStreaming(cameraSelector) {
      const liveStream = this.liveStreams.get(cameraSelector);
      if (!liveStream) {
        return;
      }
    Severity: Minor
    Found in server/services/rtsp-camera/lib/stopStreaming.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 syncUserCalendars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    async function syncUserCalendars(userId) {
      const CALDAV_HOST = await this.gladys.variable.getValue('CALDAV_HOST', this.serviceId, userId);
      const CALDAV_HOME_URL = await this.gladys.variable.getValue('CALDAV_HOME_URL', this.serviceId, userId);
      const CALDAV_USERNAME = await this.gladys.variable.getValue('CALDAV_USERNAME', this.serviceId, userId);
      const CALDAV_PASSWORD = await this.gladys.variable.getValue('CALDAV_PASSWORD', this.serviceId, userId);
    Severity: Minor
    Found in server/services/caldav/lib/calendar/calendar.syncUserCalendars.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 OpenWeatherService has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function OpenWeatherService(gladys, serviceId) {
      const { default: axios } = require('axios');
      let openWeatherApiKey;
    
      /**
    Severity: Minor
    Found in server/services/openweather/index.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 CalDAVHandler has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    const CalDAVHandler = function CalDAVHandler(gladys, serviceId, ical, dav, dayjs, xmlDom) {
    Severity: Minor
    Found in server/services/caldav/lib/index.js - About 45 mins to fix

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

      async function saveHistoricalState(deviceFeature, newValue, newValueCreatedAt) {
        // Validate that the number is correct
        if (Number.isNaN(newValue)) {
          throw new BadParameters(`device.saveHistoricalState of NaN value on ${deviceFeature.selector}`);
        }
      Severity: Minor
      Found in server/lib/device/device.saveHistoricalState.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 add has a Cognitive Complexity of 8 (exceeds 5 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 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 createActions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function createActions(store) {
        const boxActions = createBoxActions(store);
      
        const actions = {
          async getWeather(state, box, x, y) {
      Severity: Minor
      Found in front/src/actions/dashboard/boxes/weather.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 command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function command(message, classification, context) {
        let nbAffectedLights = 0;
        const roomEntity = classification.entities.find((entity) => entity.entity === 'room');
        try {
          if (!roomEntity) {
      Severity: Minor
      Found in server/lib/device/light/light.command.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function create(device) {
        // separate object
        const features = device.features || [];
        const params = device.params || [];
        delete device.features;
      Severity: Minor
      Found in server/lib/device/device.create.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 getDeviceFeaturesAggregates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      async function getDeviceFeaturesAggregates(selector, intervalInMinutes, maxStates = 100) {
        const deviceFeature = this.stateManager.get('deviceFeature', selector);
        if (deviceFeature === null) {
          throw new NotFoundError('DeviceFeature not found');
        }
      Severity: Minor
      Found in server/lib/device/device.getDeviceFeaturesAggregates.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 createActions has a Cognitive Complexity of 8 (exceeds 5 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 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 createActions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function createActions(store) {
        const houseActions = createActionsHouse(store);
        const actions = {
          async getLANManagerDevices(state) {
            store.setState({
      Severity: Minor
      Found in front/src/routes/integration/all/lan-manager/device-page/actions.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 updateFeatureProperty has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          updateFeatureProperty(state, listName, deviceIndex, featureIndex, property, value) {
      Severity: Minor
      Found in front/src/routes/integration/all/ewelink/actions.js - About 45 mins to fix

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

        const createActions = store => {
          const houseActions = createActionsHouse(store);
          const integrationActions = createActionsIntegration(store);
          const bluetoothActions = createActionsBluetooth(store);
          const actions = {
        Severity: Minor
        Found in front/src/routes/integration/all/bluetooth/setup-page/actions.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