ant-design/ant-design

View on GitHub

Showing 1,098 of 3,488 total issues

Function genBaseStyle has 241 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const genBaseStyle: GenerateStyle<DropdownToken> = (token) => {
  const {
    componentCls,
    menuCls,
    zIndexPopup,
Severity: Major
Found in components/dropdown/style/index.ts - About 1 day to fix

    Function Base has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

    const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
      const {
        prefixCls: customizePrefixCls,
        className,
        style,
    Severity: Minor
    Found in components/typography/Base/index.tsx - About 1 day 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 Header has 239 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Header: React.FC = () => {
      const [locale, lang] = useLocale(locales);
    
      const { pkg } = useSiteData();
    
    
    Severity: Major
    Found in .dumi/theme/slots/Header/index.tsx - About 1 day to fix

      File index.ts has 563 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { unit } from '@ant-design/cssinjs';
      import type { CSSObject } from '@ant-design/cssinjs';
      import type { GenStyleFn } from 'antd/es/theme/util/genComponentStyleHook';
      
      import {
      Severity: Major
      Found in components/pagination/style/index.ts - About 1 day to fix

        Function getBaseStyle has 237 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getBaseStyle: GenerateStyle<MenuToken> = (token) => {
          const {
            antCls,
            componentCls,
            fontSize,
        Severity: Major
        Found in components/menu/style/index.ts - About 1 day to fix

          File Table.pagination.test.tsx has 557 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React from 'react';
          
          import type { TablePaginationConfig, TableProps } from '..';
          import Table from '..';
          import scrollTo from '../../_util/scrollTo';
          Severity: Major
          Found in components/table/__tests__/Table.pagination.test.tsx - About 1 day to fix

            Function genInputGroupStyle has 231 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const genInputGroupStyle = (token: InputToken): CSSObject => {
              const { componentCls, antCls } = token;
            
              return {
                position: 'relative',
            Severity: Major
            Found in components/input/style/index.ts - About 1 day to fix

              File index.tsx has 551 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import * as React from 'react';
              import { defaultAlgorithm, defaultTheme } from '@ant-design/compatible';
              import {
                BellOutlined,
                FolderOutlined,
              Severity: Major
              Found in .dumi/pages/index/components/Theme/index.tsx - About 1 day to fix

                Function generateCalendar has 228 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function generateCalendar<DateType extends AnyObject>(generateConfig: GenerateConfig<DateType>) {
                  function isSameYear(date1: DateType, date2: DateType) {
                    return date1 && date2 && generateConfig.getYear(date1) === generateConfig.getYear(date2);
                  }
                
                
                Severity: Major
                Found in components/calendar/generateCalendar.tsx - About 1 day to fix

                  File index.test.tsx has 544 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /* eslint-disable react/no-unstable-nested-components */
                  import React, { useEffect, useRef } from 'react';
                  
                  import Tour from '..';
                  import mountTest from '../../../tests/shared/mountTest';
                  Severity: Major
                  Found in components/tour/__tests__/index.test.tsx - About 1 day to fix

                    Function ColorStyle has 225 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const ColorStyle: React.FC = () => {
                      const token = useTheme();
                    
                      const makePalette = (color: string, index: number = 1): string => {
                        if (index <= 10) {
                    Severity: Major
                    Found in .dumi/theme/common/Color/ColorStyle.tsx - About 1 day to fix

                      File CodePreviewer.tsx has 534 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import React, { useContext, useEffect, useRef, useState } from 'react';
                      import { LinkOutlined, ThunderboltOutlined, UpOutlined } from '@ant-design/icons';
                      import type { Project } from '@stackblitz/sdk';
                      import stackblitzSdk from '@stackblitz/sdk';
                      import { Alert, Badge, Flex, Tooltip } from 'antd';
                      Severity: Major
                      Found in .dumi/theme/builtins/Previewer/CodePreviewer.tsx - About 1 day to fix

                        File dark.tsx has 532 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // @ts-nocheck
                        import React, { useState } from 'react';
                        import { ClockCircleOutlined, DownOutlined } from '@ant-design/icons';
                        import {
                          Anchor,
                        Severity: Major
                        Found in components/modal/demo/dark.tsx - About 1 day to fix

                          Function genBaseStyle has 217 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const genBaseStyle: GenerateStyle<ListToken> = (token) => {
                            const {
                              componentCls,
                              antCls,
                              controlHeight,
                          Severity: Major
                          Found in components/list/style/index.ts - About 1 day to fix

                            File tooltip.test.tsx has 526 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import React from 'react';
                            import { spyElementPrototype } from 'rc-util/lib/test/domHook';
                            
                            import type { TooltipPlacement } from '..';
                            import Tooltip from '..';
                            Severity: Major
                            Found in components/tooltip/__tests__/tooltip.test.tsx - About 1 day to fix

                              Function genSharedBadgeStyle has 215 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const genSharedBadgeStyle: GenerateStyle<BadgeToken> = (token) => {
                                const {
                                  componentCls,
                                  iconCls,
                                  antCls,
                              Severity: Major
                              Found in components/badge/style/index.ts - About 1 day to fix

                                Function Anchor has 213 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const Anchor: React.FC<AnchorProps> = (props) => {
                                  const {
                                    rootClassName,
                                    prefixCls: customPrefixCls,
                                    className,
                                Severity: Major
                                Found in components/anchor/Anchor.tsx - About 1 day to fix

                                  Function App has 210 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const App: React.FC = () => {
                                    const [bordered, setBordered] = useState(false);
                                    const [loading, setLoading] = useState(false);
                                    const [size, setSize] = useState<SizeType>('large');
                                    const [expandable, setExpandable] = useState<ExpandableConfig<DataType> | undefined>(
                                  Severity: Major
                                  Found in components/table/demo/component-token.tsx - About 1 day to fix

                                    Function Calendar has 209 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      const Calendar = (props: CalendarProps<DateType>) => {
                                        const {
                                          prefixCls: customizePrefixCls,
                                          className,
                                          rootClassName,
                                    Severity: Major
                                    Found in components/calendar/generateCalendar.tsx - About 1 day to fix

                                      Function TransferList has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      const TransferList = <RecordType extends KeyWiseTransferItem>(
                                        props: TransferListProps<RecordType>,
                                      ) => {
                                        const {
                                          prefixCls,
                                      Severity: Minor
                                      Found in components/transfer/list.tsx - About 1 day 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