exercism/website

View on GitHub

Showing 287 of 1,075 total issues

Function drawCustomTooltip has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function drawCustomTooltip(
  ctx: CanvasRenderingContext2D,
  options: CustomTooltipOptions
) {
  const {

    Function annotateLanding has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const annotateLanding = (): void => {
      window.addEventListener('load', () => {
        const h1 = document.querySelector<HTMLElement>('#page-landing h1 strong')
    
        if (h1) {
    Severity: Major
    Found in app/javascript/utils/annotate-landing.ts - About 2 hrs to fix

      Function useThemeObserver has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function useThemeObserver(updateEndpoint?: string): ThemeData {
        const [isDarkMode, setIsDarkMode] = useState(
          window.matchMedia('(prefers-color-scheme: dark)').matches
        )
        const [themeData, setThemeData] = useState<ThemeData>({
      Severity: Major
      Found in app/javascript/hooks/use-theme-observer/index.ts - About 2 hrs to fix

        Function timeout has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const timeout = setTimeout(() => {
              const containerHeight = (canvas.parentNode as HTMLElement).offsetHeight
        
              const point0 = chart.getDatasetMeta(0).iScale.getPointLabelPosition(0)
              const label0 = labelRefs.current[0].current
        Severity: Major
        Found in app/javascript/components/profile/ContributionsSummary.tsx - About 2 hrs to fix

          Function lazyHighlightAll has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export function lazyHighlightAll(): void {
            if (!isLookbehindSupported()) return
            function applySyntaxHighlighting() {
              import('@/utils/highlight')
                .then((m) => {
          Severity: Minor
          Found in app/javascript/utils/lazy-highlight-all.ts - 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 Form has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Form = ({
            request,
            defaultAmount,
            defaultTransactionType,
            onSuccess,
          Severity: Minor
          Found in app/javascript/components/donations/Form.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

          File TestRunSummary.tsx has 270 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React from 'react'
          import { TestRun, TestRunner, TestRunStatus, TestStatus } from './types'
          import { TestRunSummaryByStatusHeaderMessage } from './TestRunSummaryByStatusHeaderMessage'
          import { TestRunOutput } from './TestRunOutput'
          import { SubmitButton } from './SubmitButton'
          Severity: Minor
          Found in app/javascript/components/editor/TestRunSummary.tsx - About 2 hrs to fix

            Function usePanel has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function usePanel(options?: any) {
              let modifiers = [
                {
                  name: 'offset',
                  options: {
            Severity: Major
            Found in app/javascript/hooks/use-panel.tsx - About 2 hrs to fix

              File languageCompartment.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { StreamLanguage } from '@codemirror/language'
              import { Compartment, Extension } from '@codemirror/state'
              
              const compartment = new Compartment()
              
              
              Severity: Minor
              Found in app/javascript/components/misc/CodeMirror/languageCompartment.ts - About 2 hrs to fix

                Function useLockedSolutionMentoringNote has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function useLockedSolutionMentoringNote(
                  request: MentorSessionRequest
                ): useLockedSolutionMentoringNoteReturns {
                  const [lockedUntil, setLockedUntil] = useState(dayjs(request.lockedUntil))
                  const [diff, setDiff] = useState(lockedUntil.diff(dayjs(), 'minute'))

                  Function onGoogleTranslateDetected has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function onGoogleTranslateDetected(): void {
                    // See: https://github.com/facebook/react/issues/11538#issuecomment-417504600
                    if (typeof Node === 'function' && Node.prototype) {
                      const originalRemoveChild: (child: Node) => Node =
                        Node.prototype.removeChild
                  Severity: Minor
                  Found in app/javascript/utils/react-bootloader.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 Component has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const Component = ({ exercises, value, setValue }: Props): JSX.Element => {
                    const [searchQuery, setSearchQuery] = useState('')
                    const [isShowingExercisesToMentor, setIsShowingExercisesToMentor] =
                      useState(true)
                    const [isShowingExercisesCompleted, setIsShowingExercisesCompleted] =
                  Severity: Minor
                  Found in app/javascript/components/mentoring/queue/ExerciseFilterList.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 useTrackWelcomeModal has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function useTrackWelcomeModal(links: TrackWelcomeModalLinks) {
                    const [open, setOpen] = useState(true)
                    const {
                      mutate: hideModal,
                      status,

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

                    export function handleNavbarFocus(): void {
                      const navElements = document.querySelectorAll<HTMLElement>(
                        '.nav-element-focusable'
                      )
                      let currentMouseOverElement: HTMLElement | null = null
                    Severity: Major
                    Found in app/javascript/utils/navbar-focus-handler.ts - About 2 hrs to fix

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

                      const tooltipReducer: ShowReducer = function (state, body) {
                        const { id, action } = body
                        const nextState: TooltipState = { ...state }
                      
                        // Use action to update the next state
                      Severity: Major
                      Found in app/javascript/hooks/use-stateful-tooltip.ts - About 2 hrs to fix

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

                        export const usePostHighlighting = (
                          posts: DiscussionPostProps[],
                          userHandle: string
                        ) => {
                          const prevLastPost = useRef<DiscussionPostProps | null>(null)

                          File notifications_mailer.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          class NotificationsMailer < ApplicationMailer
                            def mentor_started_discussion
                              notification = params[:notification]
                              @user = notification.user
                              @discussion = notification.discussion
                          Severity: Minor
                          Found in app/mailers/notifications_mailer.rb - About 2 hrs to fix

                            Function editorOptions has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const editorOptions = useMemo<SimpleMDEReactProps['options']>(() => {
                                return {
                                  autosave: contextId
                                    ? { enabled: true, uniqueId: contextId, delay: 1000 }
                                    : undefined,
                            Severity: Minor
                            Found in app/javascript/components/common/MarkdownEditor.tsx - About 1 hr to fix

                              Function useItemList has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const useItemList = <T extends ListItemType>(cacheKey: QueryKey) => {
                                const queryClient = useQueryClient()
                                const [editingItem, setEditingItem] = useState<T | null>(null)
                              
                                const handleEdit = useCallback((item) => {
                              Severity: Minor
                              Found in app/javascript/components/common/use-item-list.tsx - About 1 hr to fix

                                Function MarkdownEditorForm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const MarkdownEditorForm = ({
                                  expanded,
                                  onSubmit,
                                  onClick = () => null,
                                  onCancel,
                                Severity: Minor
                                Found in app/javascript/components/common/MarkdownEditorForm.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

                                Severity
                                Category
                                Status
                                Source
                                Language