pankod/refine

View on GitHub

Showing 163 of 230 total issues

Function Sider has 364 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Sider: React.FC = () => {
    const [collapsed, setCollapsed] = useState(false);
    const [opened, setOpened] = useState(false);

    const drawerWidth = () => {
Severity: Major
Found in packages/mui/src/components/layout/sider/index.tsx - About 1 day to fix

    Function dataProvider has 297 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const dataProvider = (client: NhostClient): DataProvider => {
        client;
        return {
            getOne: async ({ resource, id, metaData }) => {
                const operation = `${metaData?.operation ?? resource}_by_pk`;
    Severity: Major
    Found in packages/nhost/src/index.ts - About 1 day to fix

      Function LoginPage has 190 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const LoginPage: React.FC = () => {
          const {
              register,
              handleSubmit,
              formState: { errors },
      Severity: Major
      Found in packages/mui/src/components/pages/login/index.tsx - About 7 hrs to fix

        Function dataProvider has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

        const dataProvider = (supabaseClient: SupabaseClient): DataProvider => {
            return {
                getList: async ({ resource, pagination, filters, sort, metaData }) => {
                    const current = pagination?.current || 1;
                    const pageSize = pagination?.pageSize || 10;
        Severity: Minor
        Found in packages/supabase/src/index.ts - About 6 hrs 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 dataProvider has 159 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const dataProvider = (appwriteClient: Appwrite): DataProvider => {
            return {
                //TODO: Fix typing
                getList: async ({ resource, pagination, filters, sort }) => {
                    const current = pagination?.current ?? 1;
        Severity: Major
        Found in packages/appwrite/src/index.ts - About 6 hrs to fix

          Function Sider has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Sider: React.FC = () => {
              const [collapsed, setCollapsed] = useState(false);
              const [opened, setOpened] = useState(false);
          
              const drawerWidth = () => {
          Severity: Minor
          Found in packages/mui/src/components/layout/sider/index.tsx - About 5 hrs 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 ResourceComponentWrapper has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          export const ResourceComponentWrapper: React.FC<{ route: string }> = ({
              route,
          }) => {
              const { catchAll } = useRefineContext();
              const { useParams } = useRouterContext();
          Severity: Minor
          Found in packages/react-location/src/resourceComponent.tsx - About 5 hrs 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 ResourceComponent has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

          const ResourceComponent: React.FC<{ route: string }> = ({ route }) => {
              const { catchAll } = useRefineContext();
              const { useParams } = useRouterContext();
              const { resources } = useResource();
          
          
          Severity: Minor
          Found in packages/react-router-v6/src/routeProvider.tsx - About 5 hrs 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 renderTreeView has 127 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const renderTreeView = (tree: ITreeMenu[], selectedKey: string) => {
                  return tree.map((item: ITreeMenu) => {
                      const { icon, label, route, name, children, parentName } = item;
                      const isOpen = open[route || ""] || false;
          
          
          Severity: Major
          Found in packages/mui/src/components/layout/sider/index.tsx - About 5 hrs to fix

            Function RouteHandler has 127 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const RouteHandler = (val: IResourceItem): void => {
                    const { list, create, edit, show, canDelete, route, name, options } =
                        val;
            
                    const ListComponent = list;
            Severity: Major
            Found in packages/react-router/src/routeProvider.tsx - About 5 hrs to fix

              Function LoginPage has 125 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const LoginPage: React.FC = () => {
                  const [form] = Form.useForm<ILoginForm>();
                  const translate = useTranslate();
              
                  const { mutate: login, isLoading } = useLogin<ILoginForm>();
              Severity: Major
              Found in packages/antd/src/components/pages/login/index.tsx - About 5 hrs to fix

                Function ReadyPage has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const ReadyPage: React.FC = () => {
                    const renderCode = (text: string) => (
                        <Typography
                            sx={{
                                backgroundColor: (theme) =>
                Severity: Major
                Found in packages/mui/src/components/pages/ready/index.tsx - About 4 hrs to fix

                  Function useSelect has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const useSelect = <
                      TData extends BaseRecord = BaseRecord,
                      TError extends HttpError = HttpError,
                  >(
                      props: UseSelectProps<TData, TError>,
                  Severity: Major
                  Found in packages/core/src/hooks/useSelect/index.ts - About 4 hrs to fix

                    Function RouteProvider has 110 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const RouteProvider = () => {
                        const { resources } = useResource();
                        const { catchAll, DashboardPage, LoginPage } = useRefineContext();
                    
                        const { routes: customRoutes }: { routes: RouteProps[] } =
                    Severity: Major
                    Found in packages/react-router-v6/src/routeProvider.tsx - About 4 hrs to fix

                      Function Sider has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const Sider: React.FC = () => {
                          const [collapsed, setCollapsed] = useState<boolean>(false);
                          const isExistAuthentication = useIsExistAuthentication();
                          const { Link } = useRouterContext();
                          const { mutate: logout } = useLogout();
                      Severity: Major
                      Found in packages/antd/src/components/layout/sider/index.tsx - About 4 hrs to fix

                        Function renderCrud has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                const renderCrud = () => {
                                    switch (action) {
                                        case undefined:
                                            return (
                                                <CanAccess
                        Severity: Major
                        Found in packages/react-router-v6/src/routeProvider.tsx - About 3 hrs to fix

                          Function renderCrud has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  const renderCrud = () => {
                                      switch (action) {
                                          default:
                                              return (
                                                  <CanAccess
                          Severity: Major
                          Found in packages/react-location/src/resourceComponent.tsx - About 3 hrs to fix

                            Function addRouterProvider has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function addRouterProvider(j: JSCodeshift, root: Collection<any>) {
                                const routerProviderImports = root.find(j.ImportDeclaration, {
                                    source: {
                                        value: "@pankod/refine-react-router",
                                    },
                            Severity: Major
                            Found in packages/codemod/src/transformations/refine1-to-refine2.ts - About 3 hrs to fix

                              Function useMenu has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const useMenu: () => useMenuReturnType = () => {
                                  const { resources } = useResource();
                                  const translate = useTranslate();
                              
                                  const { useLocation, useParams } = useRouterContext();
                              Severity: Major
                              Found in packages/core/src/hooks/menu/useMenu.tsx - About 3 hrs to fix

                                Function RouteProviderBase has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const RouteProviderBase: React.FC = () => {
                                    const { resources } = useResource();
                                    const { catchAll, DashboardPage, LoginPage } = useRefineContext();
                                
                                    const { routes: customRoutes }: { routes: RouteProps[] } =
                                Severity: Minor
                                Found in packages/react-router/src/routeProvider.tsx - About 3 hrs 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