GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

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

function setValue(device, deviceFeature, value) {
  const externalId = deviceFeature.external_id;
  const [prefix, topic, command] = deviceFeature.external_id.split(':');

  if (prefix !== 'tasmota') {
Severity: Minor
Found in server/services/tasmota/lib/tasmota.setValue.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 newValueVibration has a Cognitive Complexity of 7 (exceeds 5 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: Minor
Found in server/services/xiaomi/lib/event/xiaomi.newValueVibration.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 getDeviceName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getDeviceName = (device) => {
  const name =
    device.name !== ''
      ? device.name
      : titleize(
Severity: Minor
Found in server/services/ewelink/lib/features/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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function init() {
  try {
    // try to connect instance to Gladys Gateway
    const gladysGatewayRefreshToken = await this.variable.getValue('GLADYS_GATEWAY_REFRESH_TOKEN');
    const gladysGatewayRsaPrivateKey = await this.variable.getValue('GLADYS_GATEWAY_RSA_PRIVATE_KEY');
Severity: Minor
Found in server/lib/gateway/gateway.init.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 refreshingTokens has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function refreshingTokens() {
  const { clientId, clientSecret } = this.configuration;
  if (!clientId || !clientSecret) {
    await this.saveStatus({ statusType: STATUS.NOT_INITIALIZED, message: null });
    throw new ServiceNotConfiguredError('Netatmo is not configured.');
Severity: Minor
Found in server/services/netatmo/lib/netatmo.refreshingTokens.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 requestEventsData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function requestEventsData(xhr, calendarUrl, eventsToUpdate, calDavHost) {
  const req = new this.dav.Request({
    method: 'REPORT',
    requestData: `
          <c:calendar-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
Severity: Minor
Found in server/services/caldav/lib/calendar/calendar.requests.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 handleAlexaMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function handleAlexaMessage(data, rawMessage, cb) {
  try {
    const service = this.serviceManager.getService('alexa');
    const body = {
      ...data.data,
Severity: Minor
Found in server/lib/gateway/gateway.handleAlexaMessage.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 checkIfBackupNeeded has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function checkIfBackupNeeded() {
  if (!this.connected) {
    logger.info(`Instance not connected to Gladys Gateway, not backing up.`);
    return;
  }
Severity: Minor
Found in server/lib/gateway/gateway.checkIfBackupNeeded.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 handleGoogleHomeMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function handleGoogleHomeMessage(data, rawMessage, cb) {
  const service = this.serviceManager.getService('google-actions');
  try {
    const body = {
      ...data.data,
Severity: Minor
Found in server/lib/gateway/gateway.handleGoogleHomeMessage.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 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 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 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((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 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 (
                <ShutterButtons
                  value={this.props.action.value}
                  category={this.state.deviceFeature.category}
                  type={this.state.deviceFeature.type}
        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 (
                <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
            Severity
            Category
            Status
            Source
            Language