Skip to content

Refactor getCursorFromHashParams function to avoid max-statements ESLint suppression #376

@coderabbitai

Description

@coderabbitai

Description

The getCursorFromHashParams function in src/utils/url/urlHash.ts currently uses an ESLint suppression comment (// eslint-disable-next-line max-statements) to bypass the max-statements rule due to its length and complexity.

Proposed Solution

Refactor the function by extracting discrete responsibilities into smaller helper functions, such as:

  • handlePrettifyChange(hashParams): boolean
  • handleTimestampParam(hashParams): number | undefined
  • handleEventNumParam(hashParams): number | undefined
  • Additional validation/normalization helpers as needed

This will make getCursorFromHashParams a thin orchestrator of these helpers, with each helper having a single responsibility and clear inputs/outputs.

Benefits

  • Improved code readability and maintainability
  • Removal of ESLint suppression
  • Better testability of individual components
  • Adherence to single responsibility principle

References

Requested by: @junhaoliao

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions