Showing 185 of 185 total issues

Function useEventAlarm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function useEventAlarm(): useEventAlarmReturn {
  const [eventLines, setEventLines] = useStorage<EventLine[]>(
    STORAGE_KEY.CALENDAR_EVENT,
  )
  const { stopAlarms } = useAlarms()
Severity: Minor
Found in src/hooks/useEventAlarm.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 insertEvent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function insertEvent(
  calendar: Calendar,
  event: CalendarEvent,
): Promise<boolean> {
  const calendarId = calendar.id
Severity: Minor
Found in src/services/google/calendar.ts - About 1 hr to fix

    Function useTaskStorage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useTaskStorage(): void {
      const { addTimes } = useTimeHistory()
      const [records, setRecords] = useRecoilState(allRecordsState)
      const key = useRecoilValue(taskRecordKeyState)
      const root = useRecoilValue(nodeState)
    Severity: Minor
    Found in src/hooks/useTaskStorage.ts - About 1 hr to fix

      Function TagMenu has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function TagMenu(props: TagMenuProps): JSX.Element {
        const [pickerVisible, setPickerVisible] = useState(false)
        const [refElm, setRefElm] = useState(null)
        const analytics = useAnalytics()
      
      
      Severity: Minor
      Found in src/components/Tag/TagMenu.tsx - About 1 hr to fix

        Function SyncButton has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function SyncButton(param: SyncButtonParam): JSX.Element {
          const [sync, setSync] = useState(false)
          const [completed, setCompleted] = useState(false)
        
          const onClick = async () => {
        Severity: Minor
        Found in src/components/Sync/SyncButton.tsx - About 1 hr to fix

          Function treeItemsToNode has 30 lines of code (exceeds 25 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

            Function ReportTable has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function ReportTable(props: Props): JSX.Element {
              const header = props.table[0]
              const table = props.table.slice(1).map((row) => {
                const key = cell2str(row[0])
                return [key, ...row]
            Severity: Minor
            Found in src/components/ReportTable.tsx - About 1 hr to fix

              Function TaskTags has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function TaskTags(props: Props): JSX.Element {
                const [hoverRef, isHovered] = useHover(200)
                const tags = props.tags.slice(0, TagCountMax)
                const isOmit = props.tags.length > TagCountMax
                const omitCount = props.tags.length - TagCountMax
              Severity: Minor
              Found in src/components/Tag/TaskTags.tsx - About 1 hr to fix

                Function TaskTag has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const TaskTag = (props: Props): JSX.Element => {
                  const tag = props.tag
                  const [pickerVisible, setPickerVisible] = useState(false)
                  const refElm = useRef<Element>(null)
                  const { tags, upsertTag } = useTagHistory()
                Severity: Minor
                Found in src/components/Tag/TaskTag.tsx - About 1 hr to fix

                  Function filter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public filter(predicate: Predicate): Node {
                      const [cloned] = clone([this])
                      const queue: Node[] = [cloned]
                      const flatten: Node[] = []
                  
                  
                  Severity: Minor
                  Found in src/models/node.ts - About 1 hr to fix

                    Function fetchColors has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function fetchColors(): Promise<CalendarColor[]> {
                      const url = 'https://www.googleapis.com/calendar/v3/colors'
                    
                      let p = new URLSearchParams()
                      p.append('key', API_KEY)
                    Severity: Minor
                    Found in src/services/google/calendar.ts - About 1 hr to fix

                      Function logout has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async logout(): Promise<boolean> {
                          let logoutResult
                      
                          const tokenType = await Storage.get(STORAGE_KEY.TOKEN_TYPE)
                          if (tokenType === TOKEN_TYPE.WEB) {
                      Severity: Minor
                      Found in src/services/google/oauth.ts - About 1 hr to fix

                        Function Sync has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function Sync(): JSX.Element {
                          const analytics = useAnalytics()
                          const [mode] = useMode()
                          const [_, setVisible] = useModal(MODAL.SYNC)
                          const [hoverRef, isHovered] = useHover(200)
                        Severity: Minor
                        Found in src/components/Menu/Sync.tsx - About 1 hr to fix

                          Function Alarm has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function Alarm(): JSX.Element {
                            const [mode] = useMode()
                            const [_, setVisible] = useModal(MODAL.ALARM)
                            const analytics = useAnalytics()
                            const [hoverRef, isHovered] = useHover(200)
                          Severity: Minor
                          Found in src/components/Menu/Alarm.tsx - About 1 hr to fix

                            Function handleKeyboard has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function handleKeyboard(e: KeyboardEvent) {
                                  switch (e.key) {
                                    case 'Enter':
                                    case ' ':
                                      if (!menuController.openSubmenu()) hide();
                            Severity: Minor
                            Found in src/lib/react-contexify/components/Menu.tsx - About 1 hr to fix

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

                                  const alarm = new Alarm({
                                    type: obj.type,
                                    name: obj.name,
                                    message: obj.message,
                                    when: obj.time,
                              Severity: Major
                              Found in src/models/alarm.ts and 1 other location - About 1 hr to fix
                              src/eventPage.ts on lines 129..135

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

                              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

                                    const alarm = new Alarm({
                                      type: param.type,
                                      name: param.name,
                                      message: param.message,
                                      when: param.scheduledTime,
                              Severity: Major
                              Found in src/eventPage.ts and 1 other location - About 1 hr to fix
                              src/models/alarm.ts on lines 30..36

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

                              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('actual'),
                                      data: groupDetails.map((g) => g[1].toHours()),
                                      backgroundColor: addOpacity(colors.blue, 0.5),
                                    },
                              Severity: Major
                              Found in src/components/Report.tsx and 1 other location - About 1 hr to fix
                              src/components/Report.tsx on lines 369..373

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

                              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: groupDetails.map((g) => g[2].toHours()),
                                      backgroundColor: addOpacity(colors.orange, 0.5),
                                    },
                              Severity: Major
                              Found in src/components/Report.tsx and 1 other location - About 1 hr to fix
                              src/components/Report.tsx on lines 364..368

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

                              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 parseStr has a Cognitive Complexity of 10 (exceeds 5 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

                              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