GladysProject/Gladys

View on GitHub

Showing 742 of 2,674 total issues

Function componentWillMount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async componentWillMount() {
    let { deviceSelector, peripheral } = this.props;
    let device;
    let loading = RequestStatus.Success;
    let isRemote;
Severity: Minor
Found in front/src/routes/integration/all/broadlink/remote-page/index.js - About 35 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 SessionDeviceLabel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const SessionDeviceLabel = ({ session }) => {
  let label;
  let icon;

  if (!session.useragent) {
Severity: Minor
Found in front/src/routes/settings/settings-session/SessionDeviceLabel.jsx - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

  render(
    props,
    {
      isGladysPlus,
      dashboardDropdownOpened,
Severity: Minor
Found in front/src/routes/dashboard/index.js - About 35 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 actions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const actions = store => ({
  updateCalendarSharing(state, e) {
    store.setState({
      calendarsSharing: {
        ...state.calendarsSharing,
Severity: Minor
Found in front/src/routes/integration/all/caldav/share-page/actions.js - About 35 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 saveDevice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async saveDevice() {
    this.setState({
      loading: true
    });
    try {
Severity: Minor
Found in front/src/routes/integration/all/mqtt/device-page/setup/index.js - About 35 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 Header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const Header = ({ ...props }) => {
  if (isUrlInArray(props.currentUrl, PAGES_WITHOUT_HEADER)) {
    return null;
  }
  // Adapt forum URL to user language
Severity: Minor
Found in front/src/components/header/index.jsx - About 35 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

Avoid too many return statements within this function.
Open

  return null;
Severity: Major
Found in server/services/rtsp-camera/lib/onNewCameraFile.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return Math.round((payload.brightness * max) / 100);
    Severity: Major
    Found in server/services/alexa/lib/deviceMappings.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return newValue;
      Severity: Major
      Found in server/services/alexa/lib/deviceMappings.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return Math.round(((lastValue - firstValue) / Math.abs(firstValue)) * 100);
        Severity: Major
        Found in front/src/components/boxs/chart/Chart.jsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return (
                <div>
                  <div className={style.explanationText}>
                    <Text id="editScene.actionsCard.deviceSetValue.simpleExplanationText" />
                  </div>
          Severity: Major
          Found in front/src/routes/scene/edit-scene/actions/DeviceSetValue.jsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return 'danger';

              Avoid too many return statements within this function.
              Open

                  return 'purple';

                Function recursiveSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const recursiveSearch = (message, callback, key = undefined) => {
                  Object.keys(message).forEach((subKey) => {
                    const currentObj = message[subKey];
                    const fullKey = `${key ? `${key}.` : ''}${subKey}`;
                
                
                Severity: Minor
                Found in server/services/tasmota/lib/features/index.js - About 25 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = (sequelize, DataTypes) => {
                  const User = sequelize.define(
                    't_user',
                    {
                      id: {
                Severity: Minor
                Found in server/models/user.js - About 25 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 scan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function scan(options) {
                  const { singleAddress, firstAddress, lastAddress, username, password } = options;
                  if (singleAddress) {
                    logger.debug(`Tasmota: HTTP looking for ${singleAddress}`);
                    this.status(singleAddress, username, password);
                Severity: Minor
                Found in server/services/tasmota/lib/http/tasmota.http.scan.js - About 25 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 RoomController has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function RoomController(gladys) {
                  /**
                   * @api {post} /api/v1/house/:house_selector/room create
                   * @apiName create
                   * @apiGroup Room
                Severity: Minor
                Found in server/api/controllers/room.controller.js - About 25 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 updateValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                async function updateValues(deviceGladys, deviceNetatmo, externalId) {
                  const [prefix, topic] = externalId.split(':');
                  const { reachable } = deviceNetatmo;
                  if (prefix !== 'netatmo') {
                    throw new BadParameters(`Netatmo device external_id is invalid: "${externalId}" should starts with "netatmo:"`);
                Severity: Minor
                Found in server/services/netatmo/lib/netatmo.updateValues.js - About 25 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 forwardDeviceStateToAlexa has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                async function forwardDeviceStateToAlexa(event) {
                  if (!this.connected) {
                    logger.debug('Gateway: not connected. Prevent forwarding device new state.');
                    return null;
                  }
                Severity: Minor
                Found in server/lib/gateway/gateway.forwardDeviceStateToAlexa.js - About 25 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 loadDeviceDetails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                async function loadDeviceDetails(homeData) {
                  const { rooms: roomsHomeData, modules: modulesHomeData, id: homeId } = homeData;
                  let listDevices = [];
                
                  logger.debug('loading devices details in home id: ', homeId, '...');
                Severity: Minor
                Found in server/services/netatmo/lib/netatmo.loadDeviceDetails.js - About 25 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