streetmix/streetmix

View on GitHub

Showing 332 of 806 total issues

Function show has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  show: function (force) {
    if (infoBubble.suppressed) {
      window.setTimeout(infoBubble.show, 100)
      return
    }
Severity: Minor
Found in client/src/info_bubble/info_bubble.js - About 1 hr to fix

Function getLabel has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function getLabel (): React.ReactElement | string {
    let id
    let defaultMessage = ''

    // Return label if provided
Severity: Minor
Found in client/src/info_bubble/InfoBubbleHeader/InfoBubbleHeader.tsx - About 1 hr to fix

Function processUrl has 44 lines of code (exceeds 25 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 1 hr to fix

Function registerKeypress has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function registerKeypress (commands, options, callback) {
  // Defaults
  // For shiftKey, metaKey, and altKey, specifies what it should
  // match on the event object reported by the browser. For instance,
  // if event.metaKey is false, it means the command must be executed
Severity: Minor
Found in client/src/app/keypress.js - About 1 hr to fix

Function componentDidUpdate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  componentDidUpdate (prevProps, prevState) {
    const { street, position, buildingWidth } = this.props
    const { variant, height } = this.state

    const lastOverflow = prevProps.street.remainingWidth < 0
Severity: Minor
Found in client/src/segments/Building.jsx - About 1 hr to fix

Function Gallery has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Gallery (): React.ReactElement {
  const { visible, instant } = useSelector((state) => state.gallery)
  const dispatch = useDispatch()
  const hide = useCallback(() => {
    void dispatch(closeGallery())
Severity: Minor
Found in client/src/gallery/Gallery.tsx - About 1 hr to fix

Function renderVariantsSelection has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function renderVariantsSelection (): Array<React.ReactElement | null> {
    const variantEls = []

    switch (type) {
      case INFO_BUBBLE_TYPE_SEGMENT: {
Severity: Minor
Found in client/src/info_bubble/InfoBubbleControls/Variants.tsx - About 1 hr to fix

Function HomepageFeatures has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function HomepageFeatures() {
  return (
    <div className="row margin-vert--lg">
      <div className="col col--4 col--offset-2" style={{ marginBottom: "1em" }}>
        <div
Severity: Minor
Found in docs/src/components/HomepageFeatures.tsx - About 1 hr to fix

Function get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export async function get (req, res) {
  // Flag error if user ID is not provided
  const userId = req.params.user_id

  const handleError = function (error) {
Severity: Minor
Found in app/resources/v1/users.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 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 client/src/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 StreetNameplateContainer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

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 client/src/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 client/src/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 SponsorBanner has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SponsorBanner (): React.ReactElement | null {
  const isSubscriber = useSelector((state) => state.user.isSubscriber)

  // Subscribers don't see sponsor banners
  if (isSubscriber) return null
Severity: Minor
Found in client/src/app/SponsorBanner.tsx - About 1 hr to fix

Function handleSegmentResizeStart has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function handleSegmentResizeStart (event) {
  let x, y
  if (app.readOnly) {
    return
  }
Severity: Minor
Found in client/src/segments/drag_and_drop.js - About 1 hr to fix

Function handleAuth0TwitterSignIn has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handleAuth0TwitterSignIn = async function (credentials) {
    try {
      const user = await User.findOne({
        where: { id: credentials.screenName }
      })
Severity: Minor
Found in app/resources/v1/users.js - About 1 hr to fix

Function LocationPopup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LocationPopup = (props) => {
  const {
    label,
    position,
    isEditable = false,
Severity: Minor
Found in client/src/dialogs/Geotag/LocationPopup.jsx - About 1 hr to fix

Function ResizeGuides has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ResizeGuides (): React.ReactElement | null {
  const isVisible = useSelector(({ ui }) => ui.resizeGuidesVisible)
  const segmentId = useSelector(({ ui }) => ui.activeSegment)
  const segment: Segment | null = useSelector(({ street }) =>
    segmentId !== null ? street.segments[segmentId] : null
Severity: Minor
Found in client/src/segments/ResizeGuides.tsx - About 1 hr to fix

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

export async function put (req, res) {
  const authUser = req.auth || {}
  const { id, comment } = req.body

  if (!authUser.sub) {
Severity: Minor
Found in app/resources/v1/votes.js - About 1 hr to fix

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

export async function get (req, res) {
  if (!req.params.street_id) {
    res.status(400).json({ status: 400, msg: 'Please provide street ID.' })
    return
  }
Severity: Minor
Found in app/resources/v1/streets.js - About 1 hr to fix

Function drawWatermark has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function drawWatermark (ctx, dpi, invert = false) {
  const text = formatMessage(
    'export.watermark',
    'Made with {streetmixWordmark}',
    {
Severity: Minor
Found in client/src/streets/thumbnail.js - About 1 hr to fix
Severity
Category
Status
Source
Language