streetmix/streetmix

View on GitHub

Showing 332 of 806 total issues

Function processMode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function processMode () {
  setServerContacted(true)

  switch (mode) {
    case MODES.ERROR:
Severity: Major
Found in client/src/app/mode.js - About 2 hrs to fix

Function drawSegmentNamesAndWidths has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function drawSegmentNamesAndWidths (
  ctx,
  street,
  dpi,
  multiplier,
Severity: Major
Found in client/src/streets/thumbnail.js - About 2 hrs to fix

Function del has a Cognitive Complexity of 16 (exceeds 5 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: Minor
Found in app/resources/v1/users_streets.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 del has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export async function del (req, res) {
  if (!req.auth) {
    res.status(401).end()
    return
  }
Severity: Minor
Found in app/resources/v1/streets.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 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 client/src/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 InfoBubbleHeader has a Cognitive Complexity of 16 (exceeds 5 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: Minor
Found in client/src/info_bubble/InfoBubbleHeader/InfoBubbleHeader.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 del has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function del (req, res) {
  if (!req.params.street_id) {
    res.status(400).json({ status: 400, msg: 'Please provide street ID.' })
    return
  }
Severity: Major
Found in app/resources/v1/street_images.js - About 2 hrs to fix

Function StreetMetaGeotag has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function StreetMetaGeotag (): React.ReactElement | null {
  const street = useSelector((state) => state.street)
  const editable = useSelector(
    (state) => !state.app.readOnly && state.flags.GEOTAG.value
  )
Severity: Major
Found in client/src/streets/StreetMeta/StreetMetaGeotag.tsx - About 2 hrs to fix

Function loadSignIn has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function loadSignIn () {
  const signInCookie = Cookies.get(SIGN_IN_TOKEN_COOKIE)
  const refreshCookie = Cookies.get(REFRESH_TOKEN_COOKIE)
  const userIdCookie = Cookies.get(USER_ID_COOKIE)

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

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

export function initCoil () {
  // Run this if browser has the monetization plugin installed. Logged-in
  // users will automatically get subscription benefits regardless of any
  // connected monetization providers
  if (document.monetization) {
Severity: Major
Found in client/src/integrations/coil.js - About 2 hrs to fix

Function drawScatteredSprites has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function drawScatteredSprites (
  sprites,
  ctx,
  width,
  offsetLeft,
Severity: Major
Found in client/src/segments/scatter.js - About 2 hrs to fix

Function handleChangeMenuSelection has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handleChangeMenuSelection = (value: string): void => {
    setEditing(false)

    const { units, width, occupiedWidth } = street
    const selection = Number.parseFloat(value)
Severity: Major
Found in client/src/streets/StreetMeta/StreetMetaWidthContainer.tsx - About 2 hrs to fix

Function recalculateWidth has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function recalculateWidth (street) {
  // Determine occupied and remaining width
  const occupiedWidth = calculateOccupiedWidth(street.segments)
  const remainingWidth = calculateRemainingWidth(street.width, occupiedWidth)
  const units = street.units
Severity: Major
Found in client/src/streets/width.js - About 2 hrs to fix

Function put has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function put (req, res) {
  let body
  try {
    body = req.body
  } catch (e) {
Severity: Minor
Found in app/resources/v1/users.js - About 2 hrs to fix

Function SentimentSurveyContainer has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SentimentSurveyContainer (props) {
  const [isVisible, setVisible] = useState(false)
  const [isDismissed, setDismissed] = useState(false)
  const [streetId, setStreetId] = useState(null)
  const street = useSelector((state) => state.street)
Severity: Minor
Found in client/src/sentiment/SentimentSurveyContainer.jsx - About 2 hrs to fix

Function UndoRedo has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function UndoRedo (): React.ReactElement {
  const undoPosition = useSelector((state) => state.history.position)
  const undoStack = useSelector((state) => state.history.stack)
  const [source, target] = useSingleton()
  const dispatch = useDispatch()
Severity: Minor
Found in client/src/palette/UndoRedo.tsx - About 1 hr to fix

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 client/src/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 incrementSegmentWidth has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const incrementSegmentWidth = (
  dataNo,
  add,
  precise,
  origWidth,
Severity: Minor
Found in client/src/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 render has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const type = this.state.type

    // Set class names
    const classNames = ['info-bubble']
Severity: Minor
Found in client/src/info_bubble/InfoBubble.jsx - About 1 hr to fix

Function FeatureFlagDialog has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function FeatureFlagDialog (props) {
  const flags = useSelector((state) => state.flags)
  const dispatch = useDispatch()

  function renderFlagList () {
Severity: Minor
Found in client/src/dialogs/FeatureFlagDialog.jsx - About 1 hr to fix
Severity
Category
Status
Source
Language