Skip to content

Commit c2937f7

Browse files
committed
refactor: sonarqube
1 parent 374980b commit c2937f7

16 files changed

Lines changed: 108 additions & 60 deletions

File tree

.scannerwork/report-task.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
projectKey=pro-react-admin
1+
projectKey=pro-react-admin2
22
serverUrl=http://localhost:9000
33
serverVersion=10.7.0.96327
4-
dashboardUrl=http://localhost:9000/dashboard?id=pro-react-admin
5-
ceTaskId=22109086-7690-4db8-bfa6-ec9a25157b56
6-
ceTaskUrl=http://localhost:9000/api/ce/task?id=22109086-7690-4db8-bfa6-ec9a25157b56
4+
dashboardUrl=http://localhost:9000/dashboard?id=pro-react-admin2
5+
ceTaskId=c3149e46-71a2-4a05-9527-1164a19fdd3d
6+
ceTaskUrl=http://localhost:9000/api/ce/task?id=c3149e46-71a2-4a05-9527-1164a19fdd3d

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"public/locales"
104104
],
105105
"sonarlint.connectedMode.project": {
106-
"connectionId": "http-localhost-9000-",
107-
"projectKey": "pro-react-admin"
106+
"connectionId": "http-localhost-9000",
107+
"projectKey": "pro-react-admin2"
108108
}
109109
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import React from 'react'
22
import { Pagination } from 'antd'
33

4-
const BasicInfo = () => (
5-
<>
6-
<Pagination defaultCurrent={6} total={500} />
7-
</>
8-
)
4+
const BasicInfo = () => <Pagination defaultCurrent={6} total={500} />
95

106
export default BasicInfo

src/components/container/landingPage/index.jsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@ import styles from './index.module.less'
88
const LandingPage = () => {
99
const navigate = useNavigate()
1010
return (
11-
<>
12-
<section className={styles.landing}>
13-
<video autoPlay loop muted src={mediaVideo} />
14-
<section className={styles.overlay} />
15-
<Button
16-
className={styles.rollback}
17-
icon={<ArrowLeftOutlined style={{ fontSize: 18 }} />}
18-
type="text"
19-
size="large"
20-
onClick={() => navigate('/')}
21-
>
22-
Roll Back
23-
</Button>
24-
</section>
25-
</>
11+
<section className={styles.landing}>
12+
<video autoPlay loop muted src={mediaVideo} />
13+
<section className={styles.overlay} />
14+
<Button
15+
className={styles.rollback}
16+
icon={<ArrowLeftOutlined style={{ fontSize: 18 }} />}
17+
type="text"
18+
size="large"
19+
onClick={() => navigate('/')}
20+
>
21+
Roll Back
22+
</Button>
23+
</section>
2624
)
2725
}
2826

src/components/container/musicPlayer/Seekbar.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react'
22
import { FastForward, Rewind } from 'lucide-react'
33
const Seekbar = ({ value, min, max, onInput, setSeekTime, appTime }) => {
44
// converts the time to format 0:00
5-
const getTime = (time) => `${Math.floor(time / 60)}:${`0${Math.floor(time % 60)}`.slice(-2)}`
5+
const getTime = (time) => {
6+
const minutes = Math.floor(time / 60)
7+
const rawSeconds = Math.floor(time % 60)
8+
const formattedSeconds = `0${rawSeconds}`.slice(-2)
9+
return `${minutes}:${formattedSeconds}`
10+
}
611

712
return (
813
<div className="hidden flex-row items-center sm:flex">
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import { useEffect, useRef, useState } from 'react'
22

33
const useCallbackState = (initialValue) => {
4-
const [state, _setState] = useState(initialValue)
4+
// Use a more descriptive name for the state value and follow the setter naming convention
5+
const [callbackState, setCallbackState] = useState(initialValue)
56
const callbackQueue = useRef([])
7+
68
useEffect(() => {
7-
callbackQueue.current.forEach((cb) => cb(state))
9+
callbackQueue.current.forEach((cb) => cb(callbackState))
810
callbackQueue.current = []
9-
}, [state])
11+
}, [callbackState])
12+
1013
const setState = (newValue, callback) => {
11-
_setState(newValue)
14+
setCallbackState(newValue)
1215
if (callback && typeof callback === 'function') {
1316
callbackQueue.current.push(callback)
1417
}
1518
}
16-
return [state, setState]
19+
20+
return [callbackState, setState]
1721
}
22+
1823
export default useCallbackState

src/components/hooks/useCookie/use-cookie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function getCookie(name: string): string | null {
6565
const cookies = document.cookie ? document.cookie.split(';') : []
6666
for (let c of cookies) {
6767
c = c.trim()
68-
if (c.indexOf(nameEq) === 0) {
68+
if (c.startsWith(nameEq)) {
6969
return decodeURIComponent(c.substring(nameEq.length))
7070
}
7171
}

src/components/hooks/useElementViewportPosition/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { useState, useEffect, RefObject } from 'react'
1+
import { useState, useEffect } from 'react'
22

33
const useElementViewportPosition = (ref = null, offset = 0) => {
44
const [position, setPosition] = useState([0, 0])
55

66
useEffect(() => {
77
const update = () => {
8-
if (!ref || !ref.current) return
8+
if (!ref?.current) return
99
const pageHeight = document.body.scrollHeight
1010
const start = ref.current.offsetTop
1111
const end = start + ref.current.offsetHeight

src/components/hooks/useRect/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const getRect = (element: HTMLElement | null): RectResult | null => {
1616
return element.getBoundingClientRect()
1717
}
1818

19-
const useRect = (): [RectResult, React.MutableRefObject<HTMLDivElement | null>] => {
19+
const useRect = (): [RectResult, React.RefObject<HTMLDivElement | null>] => {
2020
const ref = useRef<HTMLDivElement | null>(null)
2121
const current = ref.current || null
2222
const [rect, setRect] = useState(getRect(current))

src/components/hooks/useScrollIntoView/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const useScrollIntoView = ({ offset = 0 }) => {
77
const scrollIntoView = () => {
88
if (targetRef.current) {
99
const rect = targetRef.current.getBoundingClientRect()
10-
const scrollTop = window.pageYOffset || document.documentElement.scrollTop
11-
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft
10+
const scrollTop = window.scrollX || document.documentElement.scrollTop
11+
const scrollLeft = window.scrollY || document.documentElement.scrollLeft
1212
const elementTop = rect.top + scrollTop
1313
const elementLeft = rect.left + scrollLeft
1414

0 commit comments

Comments
 (0)