Showing 79 of 214 total issues
Function loadData
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const loadData = async () => {
const logFileName = routeMatch?.params.fileName;
if (!logFileName) {
return;
Function evaluateExpression
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const evaluateExpression = (
expression: string,
tuneConstants: TuneConstantsType,
config: ConfigType,
) => {
Function parse
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
parse(buffer: ArrayBuffer): this {
const raw = new TextDecoder().decode(buffer);
const xml = new DOMParser().parseFromString(raw, 'text/xml');
const xmlPages = xml.getElementsByTagName('page');
const bibliography = (xml.getElementsByTagName('bibliography')[0] as any)?.attributes;
Function ResetPassword
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ResetPassword = () => {
const [form] = Form.useForm();
const [isLoading, setIsLoading] = useState(false);
const { initResetPassword } = useAuth();
const navigate = useNavigate();
Function parse
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public parse(onProgress: (percent: number) => void): this {
let unitsIndex = 999;
const lines = this.raw.trim().split('\n');
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
Function mapSubMenuItems
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
(
rootMenuName: string,
subMenus: Record<string, SubMenuType | GroupMenuType | GroupChildMenuType>,
groupMenuName: string | null = null,
): ItemType[] => {
Function loadTune
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const loadTune = async (data: TunesResponse | null) => {
if (data === null) {
store.dispatch({ type: 'config/load', payload: null });
store.dispatch({ type: 'tune/load', payload: null });
Function keyboardZoomPlugin
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function keyboardZoomPlugin(options: ZoomPluginOptions = {}): uPlotPlugin {
const { zoomFactor = 0.9, panFactor = 0.3 } = options;
return {
hooks: {
Function userAuthMenuItems
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const userAuthMenuItems = useMemo(() => {
return currentUser
? [
{
key: 'profile',
Function uploadTune
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const uploadTune = (options: UploadRequestOption) => {
upload(
options,
(file) => {
setTuneFile(file);
Function render
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render: (tuneId: string, record: TunesResponse) => {
const isOwner = currentUser?.id === record.author;
const size = isOwner ? 'small' : 'middle';
return (
Function uploadLogs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const uploadLogs = (options: UploadRequestOption) => {
upload(
options,
(file) => {
setLogFiles((prev) => [...prev, file]);
Function parse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
public parse(onProgress: (percent: number) => void): this {
let unitsIndex = 999;
const lines = this.raw.trim().split('\n');
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
- 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 NewVersionPrompt
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const NewVersionPrompt = () => {
// fetch /version.json?v=timestamp every 10s
const { status, reloadPage } = useUpdateCheck({
type: 'interval',
interval: 10000,
Function parseToothLogs
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private parseToothLogs(raw: string): void {
this.resultTooth = [];
raw.split('\n').forEach((line) => {
const trimmed = line.trim();
Function fetchWithProgress
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const fetchWithProgress = async (
url: string,
onProgress?: OnProgress,
signal?: AbortSignal,
): Promise<ArrayBuffer> => {
Function mapSubMenuItems
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const mapSubMenuItems = (
rootMenuName: string,
rootMenu: MenuType,
subMenus: Record<string, SubMenuType | GroupMenuType | GroupChildMenuType>,
groupMenuName: string | null = null,
Function panels
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const panels = Object.keys(resolvedDialogs).map((dialogName: string): RenderedPanel => {
const currentDialog: DialogType | CurveType | TableType = resolvedDialogs[dialogName];
let type = PanelTypes.CURVE;
let fields: FieldType[] = [];
Function ready
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ready(u) {
document.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.ctrlKey || e.metaKey) {
return;
}
Function rootReducer
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const rootReducer = createReducer(initialState, (builder) => {
builder
.addCase(loadConfig, (state: AppState, action) => {
state.config = action.payload;
})