streetmix/streetmix

View on GitHub

Showing 110 of 371 total issues

Function drawSegmentContents has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

export function drawSegmentContents (
  ctx,
  type,
  variantString,
  actualWidth,
Severity: Minor
Found in assets/scripts/segments/view.js - About 1 day 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 Variants has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

function Variants (props) {
  const { type, position } = props

  // Get the appropriate variant information
  const variant = useSelector((state) => {
Severity: Minor
Found in assets/scripts/info_bubble/Variants.jsx - About 1 day 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 getVariantInfoDimensions has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

export function getVariantInfoDimensions (variantInfo, actualWidth = 0) {
  // Convert actualWidth to units that work with images' intrinsic dimensions
  const displayWidth = actualWidth * TILE_SIZE_ACTUAL

  const center = displayWidth / 2
Severity: Minor
Found in assets/scripts/segments/view.js - About 1 day 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 doDropHeuristics has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

function doDropHeuristics (draggedItem, draggedItemType) {
  // Automatically figure out width
  const street = store.getState().street
  const { variantString, type, actualWidth } = draggedItem

Severity: Minor
Found in assets/scripts/segments/drag_and_drop.js - About 1 day 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 BlockingError.jsx has 535 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * BlockingError.jsx
 *
 * Displays a blocking error message on top of the application.
 *
Severity: Major
Found in assets/scripts/app/BlockingError.jsx - About 1 day to fix

File thumbnail.js has 512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { images } from '../app/load_resources'
import { drawLine } from '../util/canvas_drawing'
import { prettifyWidth } from '../util/width_units'
import { getSkyboxDef, makeCanvasGradientStopArray } from '../sky'
import {
Severity: Major
Found in assets/scripts/streets/thumbnail.js - About 1 day to fix

File InfoBubble.jsx has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { IntlProvider, FormattedMessage } from 'react-intl'
import debounce from 'just-debounce-it'
Severity: Major
Found in assets/scripts/info_bubble/InfoBubble.jsx - About 1 day to fix

Function SaveAsImageDialog has 268 lines of code (exceeds 100 allowed). Consider refactoring.
Open

function SaveAsImageDialog (props) {
  const imageCanvas = useRef()
  const [scale, setScale] = useState(1)
  const [isLoading, setIsLoading] = useState(false)
  const [isSaving, setIsSaving] = useState(false)
Severity: Major
Found in assets/scripts/dialogs/SaveAsImageDialog.jsx - About 7 hrs to fix

Function drawSegmentContents has 252 lines of code (exceeds 100 allowed). Consider refactoring.
Open

export function drawSegmentContents (
  ctx,
  type,
  variantString,
  actualWidth,
Severity: Major
Found in assets/scripts/segments/view.js - About 7 hrs to fix

File street.ts has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { createSlice } from '@reduxjs/toolkit'
import type { PayloadAction } from '@reduxjs/toolkit'
import { getVariantString } from '../../segments/variant_utils'
import { DEFAULT_SKYBOX } from '../../sky/constants'
import {
Severity: Minor
Found in assets/scripts/store/slices/street.ts - About 5 hrs to fix

Function Variants has 196 lines of code (exceeds 100 allowed). Consider refactoring.
Open

function Variants (props) {
  const { type, position } = props

  // Get the appropriate variant information
  const variant = useSelector((state) => {
Severity: Major
Found in assets/scripts/info_bubble/Variants.jsx - About 4 hrs to fix

Function ProfileSettings has 194 lines of code (exceeds 100 allowed). Consider refactoring.
Open

function ProfileSettings (props) {
  const displayNameInputRef = useRef()
  const user = useSelector((state) => state.user.signInData?.details)
  const [displayNameValue, setDisplayNameValue] = useState(
    user.displayName || user.id
Severity: Major
Found in assets/scripts/dialogs/Settings/ProfileSettings.jsx - About 4 hrs to fix

File xhr.js has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import clone from 'just-clone'
import { showError, ERRORS } from '../app/errors'
import {
  checkIfEverythingIsLoaded,
  setServerContacted
Severity: Minor
Found in assets/scripts/streets/xhr.js - About 4 hrs to fix

Function drawBuilding has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

export function drawBuilding (
  ctx,
  variant,
  floors,
  position,
Severity: Minor
Found in assets/scripts/segments/buildings.js - About 3 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 buildings.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import seedrandom from 'seedrandom'
import { generateRandSeed } from '../util/random'
import { prettifyWidth, round } from '../util/width_units'
import { images } from '../app/load_resources'
import {
Severity: Minor
Found in assets/scripts/segments/buildings.js - About 3 hrs to fix

Function processCommands has a Cognitive Complexity of 25 (exceeds 5 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: Minor
Found in assets/scripts/app/keypress.js - About 3 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 registerKeypress has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export function registerKeypress (commands, options, callback) {
  // Defaults
  // For shiftKey, metaKey, and altKey, specifies what it should
  // match on the event object reported by the browser. For instance,
  // if event.metaKey is false, it means the command must be executed
Severity: Minor
Found in assets/scripts/app/keypress.js - About 3 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 SignInDialog.jsx has 306 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react'
import { FormattedMessage } from 'react-intl'
import {
  goEmailSignIn,
  goTwitterSignIn,
Severity: Minor
Found in assets/scripts/dialogs/SignInDialog.jsx - About 3 hrs to fix

Function Scrollable has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

const WrappedScrollable = forwardRef(function Scrollable (
  props: ScrollableProps,
  ref: React.Ref<HTMLDivElement>
): React.ReactElement {
  const {
Severity: Minor
Found in assets/scripts/ui/Scrollable.tsx - About 3 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 _signInLoaded has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function _signInLoaded () {
  loadSettings()
  const street = store.getState().street
  let mode = getMode()

Severity: Minor
Found in assets/scripts/users/authentication.js - About 3 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

Severity
Category
Status
Source
Language