streetmix/streetmix

View on GitHub

Showing 332 of 806 total issues

Function StreetMetaWidthContainer has 82 lines of code (exceeds 25 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: Major
Found in client/src/streets/StreetMeta/StreetMetaWidthContainer.tsx - 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 client/src/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 MenusContainer has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function MenusContainer (): React.ReactElement {
  const activeMenu = useSelector((state): string | null => state.menus)
  const [activeMenuItemNode, setActiveMenuItemNode] = useState<
  HTMLElement | undefined
  >(undefined)
Severity: Major
Found in client/src/menubar/MenusContainer.tsx - About 3 hrs to fix

File width_units.test.js has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { processWidthInput, prettifyWidth } from '../width_units'
import {
  SETTINGS_UNITS_IMPERIAL,
  SETTINGS_UNITS_METRIC
} from '../../users/constants'
Severity: Minor
Found in client/src/util/__tests__/width_units.test.js - About 3 hrs to fix

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 client/src/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

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.json'
Severity: Minor
Found in client/src/users/authentication.js - About 3 hrs to fix

Function Warnings has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Warnings = (props: WarningsProps): React.ReactElement | null => {
  const { segment } = props
  const messages = []

  if (segment?.warnings === undefined) return null
Severity: Major
Found in client/src/info_bubble/InfoBubbleLower/Warnings.tsx - About 3 hrs to fix

Function default has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default async function (req, res, next) {
  const userId = req.params.user_id
  const namespacedId = req.params.namespacedId

  if (!userId || !namespacedId) {
Severity: Major
Found in app/lib/request_handlers/metatags.js - About 2 hrs to fix

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

  render () {
    const { segment, enableAnalytics = true, capacitySource } = this.props

    const segmentInfo = getSegmentInfo(segment.type)

Severity: Major
Found in client/src/segments/Segment.jsx - About 2 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 client/src/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

File SaveAsImageDialog.jsx has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Save as Image (dialog box)
 *
 * Handles interaction on the "Save as image" dialog box.
 *
Severity: Minor
Found in client/src/dialogs/SaveAsImageDialog.jsx - About 2 hrs to fix

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

export async function get (req, res) {
  // Flag error if user ID is not provided
  if (!req.params.street_id) {
    res.status(400).json({ status: 400, msg: 'Please provide a street id.' })
    return
Severity: Major
Found in app/resources/v1/street_remixes.js - About 2 hrs to fix

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

export async function get (req, res) {
  // Flag error if user ID is not provided
  if (!req.params.user_id) {
    res.status(400).json({ status: 400, msg: 'Please provide user ID.' })
    return
Severity: Major
Found in app/resources/v1/users_streets.js - About 2 hrs to fix

Function del has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function del (req, res) {
  if (!req.auth) {
    res.status(401).end()
    return
  }
Severity: Major
Found in app/resources/v1/streets.js - About 2 hrs to fix

Function DebugInfo has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function DebugInfo (): React.ReactElement | null {
  const panelEl = useRef<HTMLDivElement>(null)
  const textareaEl = useRef<HTMLTextAreaElement>(null)
  const [isVisible, setVisible] = useState(false)
  const settings = useSelector((state) => state.settings)
Severity: Major
Found in client/src/app/DebugInfo.tsx - About 2 hrs to fix

Function streetsToCSV has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function streetsToCSV (json) {
  const SEGMENT_REPLACE_HEADER = '<segments>'
  const streets = json.streets

  const maxSegmentCount = streets.reduce((value, street) => {
Severity: Major
Found in app/lib/streets_export.js - About 2 hrs to fix

Function _signInLoaded has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Major
Found in client/src/users/authentication.js - About 2 hrs to fix

Function del has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function del (req, res) {
  // Flag error if user ID is not provided
  if (!req.params.user_id) {
    res.status(400).json({ status: 400, msg: 'Please provide user ID.' })
    return
Severity: Major
Found in app/resources/v1/users_streets.js - About 2 hrs to fix

Function onEverythingLoaded has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Major
Found in client/src/app/initialization.js - About 2 hrs to fix

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 client/src/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

Severity
Category
Status
Source
Language