Showing 185 of 185 total issues

Function Menu has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

export const Menu: React.FC<MenuProps> = ({
  id,
  theme,
  style,
  className,
Severity: Minor
Found in src/lib/react-contexify/components/Menu.tsx - About 3 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

  private static parseTime(taskStr: string): Time {
    if (Task.timeRegexp.test(taskStr)) {
      const m = Task.timeRegexp.exec(taskStr)
      if (m[1]) {
        return Time.parseStr(m[1])
Severity: Major
Found in src/models/task.ts and 1 other location - About 3 hrs to fix
src/models/task.ts on lines 94..103

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

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

  private static parseEstimatedTime(taskStr: string): Time {
    if (Task.estimatedTimeRegexp.test(taskStr)) {
      const m = Task.estimatedTimeRegexp.exec(taskStr)
      if (m[2]) {
        return Time.parseStr(m[2])
Severity: Major
Found in src/models/task.ts and 1 other location - About 3 hrs to fix
src/models/task.ts on lines 83..92

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

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 moveLine has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export function moveLine(
  current: number,
  from: number,
  to: number,
  length: number,
Severity: Minor
Found in src/services/util.ts - About 3 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 LineEditor has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function LineEditor(props: Props): JSX.Element {
  const line = props.line
  const manager = useTaskManager()
  const analytics = useAnalytics()
  const finishEdit = useEditFinish()
Severity: Major
Found in src/components/LineEditor.tsx - About 3 hrs to fix

    Function useTaskManager has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useTaskManager(): ITaskManager {
      const [root, setRoot] = useRecoilState<Node>(nodeState)
      const { moveTracking } = useTrackingMove()
      const { moveEventLine } = useEventAlarm()
      const { tags, upsertTag } = useTagHistory()
    Severity: Major
    Found in src/hooks/useTaskManager.ts - About 3 hrs to fix

      Function TagContextMenu has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const TagContextMenu = (props: TagContextMenuProps) => {
        const tag = props.tag
        const manager = useTaskManager()
        const [menuVisible, setMenuVisible] = useState(false)
        const [pickerVisible, setPickerVisible] = useState(false)
      Severity: Major
      Found in src/components/Tag/TagContextMenu.tsx - About 3 hrs to fix

        Function MyCalendar has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function MyCalendar(props: Props): JSX.Element {
          const [visible, setVisible] = useState(false)
          const { date, range, setDate, setDateRange } = useCalendarDate()
          const { setKey, recordKeys } = useTaskRecordKey()
          const analytics = useAnalytics()
        Severity: Major
        Found in src/components/Menu/Calendar.tsx - About 3 hrs to fix

          Function Autocomplete has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            (props: AutocompleteProps, ref: React.RefObject<HTMLDivElement>) => {
              const { tags } = useTagHistory()
              const { times } = useTimeHistory()
              const [cursor, setCursor] = useState(CURSOR_NONE)
              const tokenPosition = useRef(0)
          Severity: Minor
          Found in src/components/Autocomplete.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

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

            useEffect(() => {
              const node = ref.current
              if (node) {
                node.addEventListener('mouseenter', eventStop)
                node.addEventListener('mouseleave', eventStop)
          Severity: Major
          Found in src/hooks/useHover.ts and 1 other location - About 2 hrs to fix
          src/hooks/useHover.ts on lines 44..54

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

          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

            useEffect(() => {
              const node = hoverRef.current
              if (node) {
                node.addEventListener('mouseenter', handleMouseEnter)
                node.addEventListener('mouseleave', handleMouseLeave)
          Severity: Major
          Found in src/hooks/useHover.ts and 1 other location - About 2 hrs to fix
          src/hooks/useHover.ts on lines 63..73

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

          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 MdHeading has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const MdHeading = (props: NodeProps): JSX.Element => {
            Log.v(props.node.data)
            const manager = useTaskManager()
            const [topMargin, setTopMargin] = useState(false)
            const line = props.node.line
          Severity: Major
          Found in src/components/MdHeading.tsx - About 2 hrs to fix

            Function useTrackingState has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function useTrackingState(): useTrackingStateReturn {
              const manager = useTaskManager()
              const { appendActivities } = useActivity()
              const { setAlarmsForTask, stopAlarmsForTask } = useAlarms()
              const [trackings, setTrackings] = useRecoilState(trackingStateSelector)
            Severity: Major
            Found in src/hooks/useTrackingState.ts - About 2 hrs to fix

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

                try {
                  data = await fetchWrapper(url + '?' + p.toString())
                  if (!data) throw Error()
                } catch (err) {
                  if (err && err.message === '403') {
              Severity: Major
              Found in src/services/google/calendar.ts and 1 other location - About 2 hrs to fix
              src/services/google/calendar.ts on lines 23..32

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

              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

                try {
                  data = await fetchWrapper(url + '?' + p.toString())
                  if (!data) throw Error()
                } catch (err) {
                  if (err && err.message === '403') {
              Severity: Major
              Found in src/services/google/calendar.ts and 1 other location - About 2 hrs to fix
              src/services/google/calendar.ts on lines 192..201

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

              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 node.ts has 278 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { TreeItem } from '@/components/Tree/types'
              import { Task } from '@/models/task'
              import { Group } from '@/models/group'
              import Log from '@/services/log'
              import { rand, depthToIndent, hasProperties } from '@/services/util'
              Severity: Minor
              Found in src/models/node.ts - About 2 hrs to fix

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

                      {
                        label: i18n.t('actual'),
                        data: tagDetails.map((t) => t[1].toHours()),
                        backgroundColor: tagDetails
                          .map((t) => findColor(t[0]))
                Severity: Major
                Found in src/components/Report.tsx and 1 other location - About 2 hrs to fix
                src/components/Report.tsx on lines 351..357

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

                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

                      {
                        label: i18n.t('estimate'),
                        data: tagDetails.map((t) => t[2].toHours()),
                        backgroundColor: tagDetails
                          .map((t) => findColor(t[0]))
                Severity: Major
                Found in src/components/Report.tsx and 1 other location - About 2 hrs to fix
                src/components/Report.tsx on lines 344..350

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

                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 Copy has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function Copy(): JSX.Element {
                  const manager = useTaskManager()
                  const analytics = useAnalytics()
                  const report = useRecoilValue(reportState)
                  const [mode] = useMode()
                Severity: Major
                Found in src/components/Menu/Copy.tsx - About 2 hrs to fix

                  Function onKeyDown has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function onKeyDown(e: React.KeyboardEvent) {
                      if (e.keyCode === KEYCODE_ENTER) {
                        // KeyCode is used to distinguish it from the Enter key input during IME
                        const start = inputArea.current.selectionStart
                        const end = inputArea.current.selectionEnd
                  Severity: Major
                  Found in src/components/TodoEditor.tsx - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language