Showing 185 of 185 total issues

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

  taskToAlarms: (task: Task, alarmRules: AlarmRule[]): Alarm[] => {
    return alarmRules
      .map((rule) => {
        let minutes = 0
        let message: string
Severity: Minor
Found in src/services/alarmService.ts - 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 TagPicker has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const TagPicker = (props: Props): JSX.Element => {
  const [currentTags, setCurrentTags] = useState(props.initialTags)
  const [inputTxt, setInputTxt] = useState('')
  const [tmpTag, setTmpTag] = useState<string>(null)
  const { tags, upsertTag } = useTagHistory()
Severity: Minor
Found in src/components/Tag/TagPicker.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 Inner has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Inner(props: CalendarColorsProps): JSX.Element {
  const analytics = useAnalytics()
  const [visible, setVisible] = useState(false)
  const [refElm, setRefElm] = useState(null)
  const [colors, setColors] = useStorage<ColorStorage>(
Severity: Minor
Found in src/components/Sync/CalendarColorPicker.tsx - About 1 hr to fix

    Function parseStr has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static parseStr(timeStr: string): Time {
        const timeRegexps = [
          { type: TIME_TYPE.NEGATIVE_SIGN, regexp: /^(-)/ },
          { type: TIME_TYPE.MINUTE, regexp: /(\d+)m/ },
          { type: TIME_TYPE.HOUR, regexp: /(\d+(?:\.\d+)?)h/ },
    Severity: Minor
    Found in src/models/time.ts - About 1 hr to fix

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

        const importGoogle = async () => {
          analytics.track('import google calendar')
      
          let eventsFiltered = events.filter(
            (e) => e.responseStatus !== RESPONSE_STATUS.DECLINED,
      Severity: Minor
      Found in src/components/Sync/SyncModal.tsx - About 1 hr to fix

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

                  if (rule.timing === ALARM_TIMING.BEFORE) {
                    minutes =
                      task.estimatedTimes.toMinutes() -
                      task.actualTimes.toMinutes() -
                      rule.minutes
        Severity: Major
        Found in src/services/alarmService.ts and 1 other location - About 1 hr to fix
        src/services/alarmService.ts on lines 49..55

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

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

        export function TrackingStatus(): JSX.Element {
          const manager = useTaskManager()
          const analytics = useAnalytics()
          const [mode] = useMode()
          const { trackings } = useTrackingState()
        Severity: Minor
        Found in src/components/TrackingStatus/TrackingStatus.tsx - About 1 hr to fix

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

                    } else {
                      minutes =
                        task.estimatedTimes.toMinutes() -
                        task.actualTimes.toMinutes() +
                        rule.minutes
          Severity: Major
          Found in src/services/alarmService.ts and 1 other location - About 1 hr to fix
          src/services/alarmService.ts on lines 43..49

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

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

          export const ItemConfirm: React.FC<Props> = (props: Props): JSX.Element => {
            const [confirm, setConfirm] = useState(false)
            const [event, setEvent] = useState()
            const { hideAll } = useContextMenu()
          
          
          Severity: Minor
          Found in src/components/ContextMenu/ItemConfirm.tsx - About 1 hr to fix

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

            export function moveLine(
              current: number,
              from: number,
              to: number,
              length: number,
            Severity: Minor
            Found in src/services/util.ts - About 1 hr to fix

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

              export function Edit(): JSX.Element {
                const { stopAllTracking } = useTrackingStop()
                const analytics = useAnalytics()
                const [hoverRef, isHovered] = useHover(200)
                const [mode, setMode] = useMode()
              Severity: Minor
              Found in src/components/Menu/Edit.tsx - About 1 hr to fix

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

                export function treeItemsToNode(items: TreeItems): Node {
                  let parent = new Node(NODE_TYPE.ROOT, 0, null)
                  let queue: TreeItems = [...items]
                
                  // for ROOT
                Severity: Minor
                Found in src/services/util.ts - 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

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

                      {time.days > 0 ? (
                        <>
                          <span className="counter__days">{time.days}</span>
                          <span className="counter__unit">d</span>
                        </>
                Severity: Major
                Found in src/components/Counter.tsx and 1 other location - About 1 hr to fix
                src/components/Counter.tsx on lines 38..45

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

                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

                      {time.hours > 0 ? (
                        <>
                          <span className="counter__hours">{time.hours}</span>
                          <span className="counter__unit">h</span>
                        </>
                Severity: Major
                Found in src/components/Counter.tsx and 1 other location - About 1 hr to fix
                src/components/Counter.tsx on lines 30..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 70.

                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 LineEditor has a Cognitive Complexity of 14 (exceeds 5 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: Minor
                Found in src/components/LineEditor.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 MyCalendar has a Cognitive Complexity of 14 (exceeds 5 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: Minor
                Found in src/components/Menu/Calendar.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 getMovementAnnouncement has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function getMovementAnnouncement(
                    eventName: string,
                    activeId: UniqueIdentifier,
                    overId?: UniqueIdentifier,
                  ) {
                Severity: Minor
                Found in src/components/Tree/SortableTree.tsx - About 1 hr to fix

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

                  export function ButtonGroup(props: ButtonGroupProps): JSX.Element {
                    const [selected, setSelected] = useState<string>(props.initial)
                    const [bgLeft, setBgLeft] = useState(0)
                    const ref = useRef<HTMLButtonElement>()
                  
                  
                  Severity: Minor
                  Found in src/components/ButtonGroup.tsx - About 1 hr to fix

                    Function parse has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function parse(text: string): Node {
                      Log.v('start parse')
                      const root = new Node(NODE_TYPE.ROOT, 0, null)
                      let parent = root
                      let prevDepth = 0
                    Severity: Minor
                    Found in src/services/parser.ts - About 1 hr to fix

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

                        default: selector({
                          key: 'tagRecordStateSelector',
                          get: async () => {
                            const records = (await Storage.get(STORAGE_KEY.TASK_TAGS)) as TagRecord[]
                            if (!records) return []
                      Severity: Major
                      Found in src/hooks/useTagHistory.ts and 1 other location - About 1 hr to fix
                      src/hooks/useTrackingState.ts on lines 85..94

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

                      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