streetmix/streetmix

View on GitHub

Showing 801 of 806 total issues

Function AnalyticsDialog has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function AnalyticsDialog (): React.ReactElement {
  const street = useSelector((state) => state.street)
  const locale = useSelector((state) => state.locale.locale)
  const dispatch = useDispatch()
  const intl = useIntl()
Severity: Major
Found in client/src/dialogs/AnalyticsDialog.tsx - About 5 hrs to fix

Function NewsletterDialog has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NewsletterDialog = (props) => {
  const { register, handleSubmit } = useForm({
    progressive: true
  })
  const [submitState, setSubmitState] = useState('DEFAULT')
Severity: Major
Found in client/src/dialogs/NewsletterDialog.jsx - About 5 hrs to fix

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

                      <li>
                        <FormattedMessage
                          id="dialogs.about.font-designed-by"
                          defaultMessage="{fontName} font designed by {fontAuthor}."
                          values={{
Severity: Major
Found in client/src/dialogs/AboutDialog.tsx and 2 other locations - About 5 hrs to fix
client/src/dialogs/AboutDialog.tsx on lines 146..178
client/src/dialogs/AboutDialog.tsx on lines 179..211

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 145.

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 3 locations. Consider refactoring.
Open

                      <li>
                        <FormattedMessage
                          id="dialogs.about.font-designed-by"
                          defaultMessage="{fontName} font designed by {fontAuthor}."
                          values={{
Severity: Major
Found in client/src/dialogs/AboutDialog.tsx and 2 other locations - About 5 hrs to fix
client/src/dialogs/AboutDialog.tsx on lines 113..145
client/src/dialogs/AboutDialog.tsx on lines 179..211

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 145.

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 3 locations. Consider refactoring.
Open

                      <li>
                        <FormattedMessage
                          id="dialogs.about.font-designed-by"
                          defaultMessage="{fontName} font designed by {fontAuthor}."
                          values={{
Severity: Major
Found in client/src/dialogs/AboutDialog.tsx and 2 other locations - About 5 hrs to fix
client/src/dialogs/AboutDialog.tsx on lines 113..145
client/src/dialogs/AboutDialog.tsx on lines 146..178

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 145.

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

describe('getSegmentComponentInfo()', () => {
  it('returns data for a segment component', () => {
    const component = getSegmentComponentInfo('lanes', 'sidewalk')
    expect(component.unknown).toBeFalsy()
  })
Severity: Major
Found in client/src/segments/__tests__/segment-dict.test.js and 1 other location - About 5 hrs to fix
client/src/segments/__tests__/info.test.js on lines 69..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 144.

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

  describe('getSegmentVariantInfo()', () => {
    it('returns data for a segment variant', () => {
      const variant = getSegmentVariantInfo('sidewalk', 'normal')
      expect(variant.unknown).toBeFalsy()
    })
Severity: Major
Found in client/src/segments/__tests__/info.test.js and 1 other location - About 5 hrs to fix
client/src/segments/__tests__/segment-dict.test.js on lines 23..38

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 144.

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

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

import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import debounce from 'just-debounce-it'

Severity: Minor
Found in client/src/info_bubble/InfoBubble.jsx - About 5 hrs to fix

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

      <Tooltip
        target={target}
        label={intl.formatMessage({ id: 'btn.undo', defaultMessage: 'Undo' })}
      >
        {/* Keep title on button to be queryable by test */}
Severity: Major
Found in client/src/palette/UndoRedo.tsx and 1 other location - About 5 hrs to fix
client/src/palette/UndoRedo.tsx on lines 49..63

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 141.

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

      <Tooltip
        target={target}
        label={intl.formatMessage({ id: 'btn.redo', defaultMessage: 'Redo' })}
      >
        {/* Keep title on button to be queryable by test */}
Severity: Major
Found in client/src/palette/UndoRedo.tsx and 1 other location - About 5 hrs to fix
client/src/palette/UndoRedo.tsx on lines 34..48

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 141.

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

  describe('increase width', () => {
    it('increases store width', async () => {
      const { store } = render(<WidthControl position={activeElement} />, {
        initialState: { street: { segments: [segment], units: 0 } }
      })
client/src/info_bubble/InfoBubbleControls/WidthControl.test.tsx on lines 39..50

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 141.

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

  describe('decrease width', () => {
    it('decreases store width', async () => {
      const { store } = render(<WidthControl position={activeElement} />, {
        initialState: { street: { segments: [segment], units: 0 } }
      })
client/src/info_bubble/InfoBubbleControls/WidthControl.test.tsx on lines 26..37

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 141.

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 35 (exceeds 5 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: Minor
Found in app/resources/v1/street_images.js - About 5 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 drawBuilding has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Function ToastContainer has 127 lines of code (exceeds 25 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 client/src/ui/Toasts/ToastContainer.tsx - About 5 hrs to fix

File users.js has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import cloudinary from 'cloudinary'
import models from '../../db/models/index.js'
import logger from '../../lib/logger.js'
import { ERRORS, asUserJson, asUserJsonBasic } from '../../lib/util.js'

Severity: Minor
Found in app/resources/v1/users.js - About 5 hrs to fix

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

export async function put (req, res) {
  let body

  if (req.body) {
    try {
Severity: Major
Found in app/resources/v1/streets.js - About 4 hrs to fix

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

function GalleryStreetItem (
  props: GalleryStreetItemProps
): React.ReactElement | null {
  const {
    street,
Severity: Major
Found in client/src/gallery/GalleryStreetItem.tsx - About 4 hrs to fix

Function find has 122 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function find (req, res) {
  const creatorId = req.query.creatorId
  const namespacedId = req.query.namespacedId
  const start = (req.query.start && Number.parseInt(req.query.start, 10)) || 0
  const count = (req.query.count && Number.parseInt(req.query.count, 10)) || 20
Severity: Major
Found in app/resources/v1/streets.js - About 4 hrs to fix

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

  it('should respond with 403 Forbidden when user is not owner of street', () => {
    cloudinary.v2.api.resource.mockResolvedValueOnce('baz')

    jwtMock.mockReturnValueOnce(mockAltUser)

Severity: Major
Found in app/resources/v1/__tests__/street_images.test.js and 1 other location - About 4 hrs to fix
app/resources/v1/__tests__/street_images.test.js on lines 46..56

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 132.

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

Severity
Category
Status
Source
Language