Showing 137 of 185 total issues
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)
- Read upRead up
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 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
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)
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'
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()
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
Time
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class Time {
static parseMs(ms: number): Time {
const time = new Time()
if (ms < 0) {
time._isNegative = true
Function MdWrapper
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const MdWrapper: React.FC<Props> = (props: Props): JSX.Element => {
const manager = useTaskManager()
const [_, __, edit] = useEditable(props.line)
const { trackings } = useTrackingState()
const tracking = trackings.find((n) => n.line === props.line)
Function Menu
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function Menu(): JSX.Element {
const [isFixed, setFixed] = useState(false)
const [mode, setMode] = useMode()
const isReport = mode === MODE.REPORT
const analytics = useAnalytics()
Function BasePicker
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const BasePicker = (props: BasePickerProps): JSX.Element => {
const eventType = props.eventType || EVENT_TYPE.CLICK
const [boundaryRef, isBoundaryHovered] = useHover()
const [overlayRef, isOverlayHovered] = useHover()
const [contentRef] = useHoverCancel()
Function TaskItem
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const TaskItem: React.FC<TaskItemProps> = (
props: TaskItemProps,
): JSX.Element => {
const checkboxProps = props.checkboxProps
const node = props.node
- Read upRead up
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 Item
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const Item: React.FC<ItemProps> = ({
id,
children,
className,
style,
- Read upRead up
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 useActivity
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useActivity(): useActivityReturn {
const [uploadParam, setUploadParam] = useState<UploadParam>()
const [activities, setActivities] = useStorage<CalendarEvent[]>(
STORAGE_KEY.ACTIVITIES,
)
Function AlarmModal
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function AlarmModal(): JSX.Element {
const analytics = useAnalytics()
const { alarms } = useAlarms()
const [visible, setVisible] = useModal(MODAL.ALARM)
const alarmExists = alarms?.length > 0
Function Report
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function Report(): JSX.Element {
const [report, setReport] = useRecoilState(reportState)
const [onlyCompleted, setOnlyCompleted] = useState(true)
const { tags } = useTagHistory()
const manager = useTaskManager()
- Read upRead up
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 PlayStopButton
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function PlayStopButton(props: PlayStopProps) {
const { date } = useCalendarDate()
const [tooltipVisible, setTooltipVisible] = useState(false)
const [timeoutID, setTimeoutID] = useState<number>()
const available = props.available && isToday(date)
Function TagButton
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const TagButton = (props: TagButtonProps): JSX.Element => {
const tag = props.tag
const { tags } = useTagHistory()
const tagRecord = tags.find((t) => t.name === tag.name)
const initialBg = tagRecord?.colorHex || COLOR.Gray200
Function fetchEvents
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function fetchEvents(calendar: Calendar): Promise<CalendarEvent[]> {
if (!calendar) return []
const calendarId = calendar.id
const timeZone = calendar.timeZone
const url = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events`
Function useEventAlarm
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function useEventAlarm(): useEventAlarmReturn {
const [eventLines, setEventLines] = useStorage<EventLine[]>(
STORAGE_KEY.CALENDAR_EVENT,
)
const { stopAlarms } = useAlarms()
Function fetchRefreshToken
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchRefreshToken(): Promise<boolean> {
Log.d('fetchRefreshToken')
return new Promise(async (resolve) => {
const S = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const state = Array.from(crypto.getRandomValues(new Uint8Array(12)))