streetmix/streetmix

View on GitHub

Showing 110 of 370 total issues

File authentication.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Cookies from 'js-cookie'
import { jwtDecode } from 'jwt-decode'
import * as Sentry from '@sentry/browser'

import USER_ROLES from '../../../app/data/user_roles'
Severity: Minor
Found in assets/scripts/users/authentication.js - About 3 hrs to fix

Function deregisterKeypress has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export function deregisterKeypress (commands, callback) {
  const commandObj = processCommands(commands)

  // Process each command input
  for (const key in commandObj) {
Severity: Minor
Found in assets/scripts/app/keypress.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 processUrl has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function processUrl () {
  // Get current pathname. The pathname will contain an initial `/` followed
  // by the path of the URL. The root pathname should always be `/`. It may
  // be possible for the URL to contain a trailing slash, but we don't want
  // that, so remove it, if present. This will cause the root pathname to be
Severity: Minor
Found in assets/scripts/app/page_url.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

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

/**
 * About Streetmix (dialog box)
 *
 * Renders the "About" dialog box.
 *
Severity: Minor
Found in assets/scripts/dialogs/AboutDialog.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 assets/scripts/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

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

/* 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 assets/scripts/dialogs/GeotagDialog.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 assets/scripts/app/StreetView.jsx - About 2 hrs to fix

Function drawBuilding has 129 lines of code (exceeds 100 allowed). Consider refactoring.
Open

export function drawBuilding (
  ctx,
  variant,
  floors,
  position,
Severity: Major
Found in assets/scripts/segments/buildings.js - About 2 hrs to fix

Function errorReceiveStreet has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function errorReceiveStreet (error) {
  const data = error.response.data
  const mode = getMode()
  if (
    mode === MODES.CONTINUE ||
Severity: Minor
Found in assets/scripts/streets/xhr.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 ToastContainer has 127 lines of code (exceeds 100 allowed). Consider refactoring.
Open

function ToastContainer (): React.ReactElement {
  const config = TOAST_SPRING_CONFIG
  const [refMap] = useState(() => new WeakMap())
  const [cancelMap] = useState(() => new WeakMap())
  const toasts = useSelector((state) => state.toasts)
Severity: Major
Found in assets/scripts/ui/Toasts/ToastContainer.tsx - About 2 hrs to fix

Function GalleryStreetItem has 123 lines of code (exceeds 100 allowed). Consider refactoring.
Open

function GalleryStreetItem (
  props: GalleryStreetItemProps
): React.ReactElement | null {
  const {
    street,
Severity: Major
Found in assets/scripts/gallery/GalleryStreetItem.tsx - About 1 hr to fix

Function incrementSegmentWidth has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const incrementSegmentWidth = (
  dataNo,
  add,
  precise,
  origWidth,
Severity: Minor
Found in assets/scripts/store/actions/street.js - About 1 hr 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 hover has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  hover (props, monitor, component) {
    if (!monitor.canDrop()) return

    const dragIndex = monitor.getItem().dataNo
    const hoverIndex = props.dataNo
Severity: Minor
Found in assets/scripts/segments/drag_and_drop.js - About 1 hr 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 Scrollable has 119 lines of code (exceeds 100 allowed). Consider refactoring.
Open

const WrappedScrollable = forwardRef(function Scrollable (
  props: ScrollableProps,
  ref: React.Ref<HTMLDivElement>
): React.ReactElement {
  const {
Severity: Major
Found in assets/scripts/ui/Scrollable.tsx - About 1 hr to fix

Function StreetNameplateContainer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Confirmed

function StreetNameplateContainer (props) {
  const isVisible = useSelector((state) => !state.ui.welcomePanelVisible)
  const isEditable = useSelector(
    (state) => !state.app.readOnly && state.flags.EDIT_STREET_NAME.value
  )
Severity: Minor
Found in assets/scripts/streets/StreetNameplateContainer.jsx - About 1 hr 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 NotificationBar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function NotificationBar ({
  notification = {}
}: NotificationBarProps): React.ReactElement | null {
  const locale = useSelector((state) => state.locale)
  const {
Severity: Minor
Found in assets/scripts/app/NotificationBar/NotificationBar.tsx - About 1 hr 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 GalleryStreetItem has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function GalleryStreetItem (
  props: GalleryStreetItemProps
): React.ReactElement | null {
  const {
    street,
Severity: Minor
Found in assets/scripts/gallery/GalleryStreetItem.tsx - About 1 hr 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 118 lines of code (exceeds 100 allowed). Consider refactoring.
Open

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

Severity: Major
Found in assets/scripts/segments/drag_and_drop.js - About 1 hr to fix

Function BuildingHeightControl has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function BuildingHeightControl ({ position }) {
  const units = useSelector((state) => state.street.units)

  // Get the appropriate building data based on which side of street it's on
  const variant = useSelector((state) =>
Severity: Minor
Found in assets/scripts/info_bubble/BuildingHeightControl.jsx - About 1 hr 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 show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  show: function (force) {
    if (infoBubble.suppressed) {
      window.setTimeout(infoBubble.show, 100)
      return
    }
Severity: Minor
Found in assets/scripts/info_bubble/info_bubble.js - About 1 hr 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