streetmix/streetmix

View on GitHub

Showing 801 of 806 total issues

File streets.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { v4 as uuidv4 } from 'uuid'
import models from '../../db/models/index.js'
import logger from '../../lib/logger.js'
import { ERRORS, asStreetJson } from '../../lib/util.js'
import { updateToLatestSchemaVersion } from '../../lib/street_schema_update.js'
Severity: Major
Found in app/resources/v1/streets.js - 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 client/src/streets/thumbnail.js - About 1 day to fix

Function Variants has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

function Variants (props: VariantsProps): React.ReactElement | null {
  const { type, position } = props

  // Get the appropriate variant information
  const variant = useSelector((state) => {
Severity: Minor
Found in client/src/info_bubble/InfoBubbleControls/Variants.tsx - 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 202 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Variants (props: VariantsProps): React.ReactElement | null {
  const { type, position } = props

  // Get the appropriate variant information
  const variant = useSelector((state) => {
Severity: Major
Found in client/src/info_bubble/InfoBubbleControls/Variants.tsx - About 1 day to fix

Function ProfileSettings has 199 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ProfileSettings (): React.ReactElement | null {
  const displayNameInputRef = useRef<HTMLInputElement>(null)
  const user = useSelector((state) => state.user.signInData?.details)
  const [displayNameValue, setDisplayNameValue] = useState(
    user?.displayName ?? user?.id ?? ''
Severity: Major
Found in client/src/dialogs/Settings/ProfileSettings.tsx - About 7 hrs to fix

File view.js has 492 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { images } from '../app/load_resources'
import { formatMessage } from '../locales/locale'
import { saveStreetToServerIfNecessary } from '../streets/data_model'
import { recalculateWidth } from '../streets/width'
import store from '../store'
Severity: Minor
Found in client/src/segments/view.js - About 7 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  function handleErrors (error) {
    switch (error) {
      case ERRORS.USER_NOT_FOUND:
        res.status(404).json({ status: 404, msg: 'User not found.' })
        return
Severity: Major
Found in app/resources/v1/streets.js and 1 other location - About 7 hrs to fix
app/resources/v1/streets.js on lines 124..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 189.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  function handleErrors (error) {
    switch (error) {
      case ERRORS.USER_NOT_FOUND:
        res.status(404).json({ status: 404, msg: 'User not found.' })
        return
Severity: Major
Found in app/resources/v1/streets.js and 1 other location - About 7 hrs to fix
app/resources/v1/streets.js on lines 212..232

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 189.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function post has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

export async function post (req, res) {
  const handleCreateUser = function (user) {
    if (!user) {
      res.status(500).json({
        status: 500,
Severity: Minor
Found in app/resources/v1/users.js - About 7 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <div className="col col--4 col--offset-2" style={{ marginBottom: "1em" }}>
        <div
          className="text--center padding-horiz--md"
          style={{ height: "100%" }}
        >
Severity: Major
Found in docs/src/components/HomepageFeatures.tsx and 1 other location - About 7 hrs to fix
docs/src/components/HomepageFeatures.tsx on lines 30..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 185.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <div className="col col--4" style={{ marginBottom: "1em" }}>
        <div
          className="text--center padding-horiz--md"
          style={{ height: "100%" }}
        >
Severity: Major
Found in docs/src/components/HomepageFeatures.tsx and 1 other location - About 7 hrs to fix
docs/src/components/HomepageFeatures.tsx on lines 10..29

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 185.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

export async function post (req, res) {
  const handleCreateUser = function (user) {
    if (!user) {
      res.status(500).json({
        status: 500,
Severity: Major
Found in app/resources/v1/users.js - About 7 hrs to fix

Function UpDownInput has 180 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function UpDownInput (props: UpDownInputProps): React.ReactElement {
  // Destructure props with default values
  const {
    value,
    minValue,
Severity: Major
Found in client/src/info_bubble/InfoBubbleControls/UpDownInput.tsx - About 7 hrs to fix

Function post has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

export async function post (req, res) {
  let body
  const street = {}
  street.id = uuidv4()
  const requestIp = function (req) {
Severity: Minor
Found in app/resources/v1/streets.js - About 6 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 GeotagDialog has 169 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function GeotagDialog () {
  // this kinda goofy props object is a result of refactoring
  // some legacy code. definetly worth refactoring further in the future
  // if it causes other problems or confusion
  const props = {
Severity: Major
Found in client/src/dialogs/GeotagDialog.jsx - About 6 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('handles different hostname cases', () => {
    expect(isUrlExternal('http://example.com', SELF_HOSTNAME)).toBeTruthy()
    expect(
      isUrlExternal('http://example.com/with/path/params', SELF_HOSTNAME)
    ).toBeTruthy()
Severity: Major
Found in client/src/util/__tests__/helpers.test.js and 1 other location - About 6 hrs to fix
client/src/util/__tests__/helpers.test.js on lines 62..84

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 165.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('handles same hostname cases', () => {
    expect(isUrlExternal('http://streetmix.net', SELF_HOSTNAME)).toBeFalsy()
    expect(
      isUrlExternal('http://streetmix.net/with/path/params', SELF_HOSTNAME)
    ).toBeFalsy()
Severity: Major
Found in client/src/util/__tests__/helpers.test.js and 1 other location - About 6 hrs to fix
client/src/util/__tests__/helpers.test.js on lines 86..108

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 165.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function post has 149 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

export async function post (req, res) {
  let json

  // The request payload is a stringified JSON due to the data URL for the street thumbnail being too large.
  // Setting the bodyParser.text({ limit }) works for a specific route whereas bodyParser.json({ limit }) does not.
Severity: Major
Found in app/resources/v1/street_images.js - About 5 hrs to fix

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

  render () {
    const { sendingEmail, emailSent, signingIn } = this.state

    if (sendingEmail || signingIn) {
      return this.renderSignInWaiting()
Severity: Major
Found in client/src/dialogs/SignInDialog.jsx - About 5 hrs to fix

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

export async function post (req, res) {
  let body
  const street = {}
  street.id = uuidv4()
  const requestIp = function (req) {
Severity: Major
Found in app/resources/v1/streets.js - About 5 hrs to fix
Severity
Category
Status
Source
Language