streetmix/streetmix

View on GitHub

Showing 332 of 806 total issues

Function getSharingMessage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function getSharingMessage (
  street: StreetState,
  user: UserState,
  intl: IntlShape
): string {
Severity: Minor
Found in client/src/menubar/menus/ShareMenu/helpers.ts - About 2 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

File AboutDialog.tsx has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { memo } from 'react'
import { FormattedMessage } from 'react-intl'

import { useSelector } from '../store/hooks'
import ExternalLink from '../ui/ExternalLink'
Severity: Minor
Found in client/src/dialogs/AboutDialog.tsx - About 2 hrs to fix

Function renderButton has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function renderButton (
    set: string,
    selection: string
  ): React.ReactElement | null {
    const icon = VARIANT_ICONS[set][selection]
Severity: Major
Found in client/src/info_bubble/InfoBubbleControls/Variants.tsx - About 2 hrs to fix

Function processCommands has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function processCommands (commands) {
  // If a string, force to one-element array, otherwise expect an array of strings
  if (typeof commands === 'string') {
    commands = new Array(commands)
  }
Severity: Major
Found in client/src/app/keypress.js - About 2 hrs to fix

Function SkyPicker has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SkyPicker (): React.ReactElement {
  const selected = useSelector(
    (state) => state.street.skybox || DEFAULT_SKYBOX
  )
  const show = useSelector((state) => state.ui.toolboxVisible || false)
Severity: Major
Found in client/src/sky/SkyPicker/SkyPicker.tsx - About 2 hrs to fix

Function FirstTimeExistingStreet has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function FirstTimeExistingStreet (props) {
  const street = useSelector((state) => state.street)
  const { data: creatorProfile } = useGetUserQuery(street.creatorId)

  function handleGoNewStreet (event) {
Severity: Major
Found in client/src/app/WelcomePanel/FirstTimeExistingStreet.jsx - About 2 hrs to fix

Function onEverythingLoaded has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function onEverythingLoaded () {
  if (getMode() === MODES.NEW_STREET_COPY_LAST) {
    fetchLastStreet()
  }

Severity: Minor
Found in client/src/app/initialization.js - About 2 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

Function StreetMetaWidthContainer has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function StreetMetaWidthContainer (): React.ReactElement {
  const street = useSelector((state) => state.street)
  const editable = useSelector(
    (state) => !state.app.readOnly && state.flags.EDIT_STREET_WIDTH.value
  )
Severity: Minor
Found in client/src/streets/StreetMeta/StreetMetaWidthContainer.tsx - About 2 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

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

  render () {
    const classNames = ['blocking-shield']

    if (this.state.visible) {
      classNames.push('visible')
Severity: Major
Found in client/src/app/BlockingShield.jsx - About 2 hrs to fix

Function InfoBubbleHeader has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function InfoBubbleHeader (props: InfoBubbleHeaderProps): React.ReactElement {
  const { type, position } = props
  const { locale, segmentInfo } = useSelector((state) => state.locale)
  const street = useSelector((state) => state.street)

Severity: Major
Found in client/src/info_bubble/InfoBubbleHeader/InfoBubbleHeader.tsx - About 2 hrs to fix

Function initCoil has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const initCoil = () => {
  const authToken = btoa(
    process.env.COIL_CLIENT_ID +
      ':' +
      encodeURIComponent(process.env.COIL_CLIENT_SECRET)
Severity: Major
Found in app/resources/services/integrations/coil.js - About 2 hrs to fix

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

export async function get (req, res) {
  // Flag error if user ID is not provided
  const userId = req.params.user_id

  const handleError = function (error) {
Severity: Major
Found in app/resources/v1/users.js - About 2 hrs to fix

File GeotagDialog.jsx has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global L */
import React, { useState } from 'react'
import PropTypes from 'prop-types'
import { useSelector, useDispatch, batch } from 'react-redux'
import { useIntl } from 'react-intl'
Severity: Minor
Found in client/src/dialogs/GeotagDialog.jsx - About 2 hrs to fix

Function SocialLinks has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SocialLinks (): React.ReactElement {
  return (
    <ul className="social-links">
      <li>
        <a
Severity: Major
Found in client/src/dialogs/About/SocialLinks.tsx - About 2 hrs to fix

Function getSharingMessage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function getSharingMessage (
  street: StreetState,
  user: UserState,
  intl: IntlShape
): string {
Severity: Major
Found in client/src/menubar/menus/ShareMenu/helpers.ts - About 2 hrs to fix

Function post has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function post (req, res) {
  const authUser = req.auth || {}

  if (!authUser.sub) {
    res.status(401).json({ status: 401, msg: 'Please provide user ID.' })
Severity: Major
Found in app/resources/v1/votes.js - About 2 hrs to fix

Function registerKeypresses has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function registerKeypresses () {
  // In case anyone tries a save shortcut key out of reflex,
  // we inform the user that it's not necessary.
  registerKeypress('ctrl s', function () {
    store.dispatch(
Severity: Major
Found in client/src/app/keyboard_commands.js - About 2 hrs to fix

File votes.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Sequelize from 'sequelize'
import { v4 as uuidv4 } from 'uuid'
import models from '../../db/models/index.js'
import logger from '../../lib/logger.js'

Severity: Minor
Found in app/resources/v1/votes.js - About 2 hrs to fix

Function SentimentSurveyDialog has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SentimentSurveyDialog (props) {
  return (
    <Dialog>
      {(closeDialog) => (
        <div className="sentiment-survey-about-dialog">
Severity: Major
Found in client/src/dialogs/SentimentSurveyDialog.jsx - About 2 hrs to fix

File StreetView.jsx has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * StreetView.jsx
 *
 * Renders the street view.
 *
Severity: Minor
Found in client/src/app/StreetView.jsx - About 2 hrs to fix
Severity
Category
Status
Source
Language