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()
- 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 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
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)
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()
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 () => {
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
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]
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
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()
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[] = []
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)
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) {
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)
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)
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();
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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),
},
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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),
},
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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/ },
- 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"