pankod/refine

View on GitHub

Showing 959 of 983 total issues

Function ExampleImplementation has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ExampleImplementation = () => {
  return (
    <pre
      style={{
        display: "block",
Severity: Major
Found in packages/core/src/components/pages/config-error/index.tsx - About 3 hrs to fix

    Function moveResources has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const moveResources = (j: JSCodeshift, root: Collection<any>) => {
      const newResources: { [key: string]: any }[] = [];
    
      const resourceElements = root.find(j.JSXElement, {
        openingElement: {
    Severity: Major
    Found in packages/codemod/src/transformations/refine1-to-refine2.ts - About 3 hrs to fix

      Function renderTreeView has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const renderTreeView = (tree: ITreeMenu[]) => {
          return tree.map((item) => {
            const { label, route, name, icon, children } = item;
      
            const isSelected = item.key === selectedKey;
      Severity: Major
      Found in packages/chakra-ui/src/components/layout/sider/index.tsx - About 3 hrs to fix

        Function updateRefineImports has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function Create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Create: React.FC<CreateProps> = (props) => {
            const {
              children,
              saveButtonProps: saveButtonPropsFromProps,
              isLoading,
          Severity: Minor
          Found in packages/mantine/src/components/crud/create/index.tsx - About 2 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 mediaUploadMapper has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export const mediaUploadMapper = (params: any) => {
            Object.keys(params).map((item) => {
              if (params[item]) {
                const param = params[item].fileList;
                const isMediaField = Array.isArray(param);
          Severity: Minor
          Found in packages/strapi-v4/src/helpers/normalize.ts - About 2 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 a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export const dataProvider = (
            apiUrl: string,
            httpClient: AxiosInstance = axiosInstance,
          ): Omit<
            Required<DataProvider>,
          Severity: Minor
          Found in packages/simple-rest/src/provider.ts - About 2 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 reorderImports has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export const reorderImports = (content: string): string => {
            let newContent = content;
            // imports can have comments before them, we need to preserve those comments and import statements.
            // so we need to filter out the imports with comments before.
            const allImports = getImports(content);
          Severity: Minor
          Found in packages/cli/src/utils/swizzle/import.ts - About 2 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 useResource has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export function useResource(
            args?: UseResourceLegacyProps | UseResourceParam,
          ): UseResourceReturnType {
            const { resources } = useContext(ResourceContext);
          
          
          Severity: Minor
          Found in packages/core/src/hooks/resource/useResource/index.ts - About 2 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 convertToLegacy has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function convertToLegacy(segments: KeySegment[]) {
            // for `list`, `many` and `one`
            if (segments[0] === "data") {
              // [data, dpName, resource, action, ...];
              const newSegments = segments.slice(1);
          Severity: Major
          Found in packages/core/src/definitions/helpers/keys/index.ts - About 2 hrs to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            export const useSiderVisible = (): UseSiderVisibleType => {
              const {
                mobileSiderOpen,
                siderCollapsed,
                setMobileSiderOpen,
            Severity: Major
            Found in packages/chakra-ui/src/hooks/useSiderVisible/index.ts and 1 other location - About 2 hrs to fix
            packages/mui/src/hooks/useSiderVisible/index.ts on lines 15..29

            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 91.

            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

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            export const useSiderVisible = (): UseSiderVisibleType => {
              const {
                mobileSiderOpen,
                siderCollapsed,
                setMobileSiderOpen,
            Severity: Major
            Found in packages/mui/src/hooks/useSiderVisible/index.ts and 1 other location - About 2 hrs to fix
            packages/chakra-ui/src/hooks/useSiderVisible/index.ts on lines 15..29

            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 91.

            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

            Further Reading

            Function go has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              go: () => {
                const { push, replace } = useRouter();
                const pathname = usePathname();
                const searchParamsObj = useSearchParams();
            
            
            Severity: Minor
            Found in packages/nextjs-router/src/app/bindings.tsx - About 2 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 List has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            export const List: React.FC<ListProps> = (props) => {
              const {
                canCreate,
                children,
                createButtonProps: createButtonPropsFromProps,
            Severity: Minor
            Found in packages/chakra-ui/src/components/crud/list/index.tsx - About 2 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 PackageItem has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            export const PackageItem = ({ item, blocked, onUpdate, onOutdated }: Props) => {
              const [latestLoading, setLatestLoading] = React.useState(true);
              const [latestData, setLatestData] =
                React.useState<PackageLatestVersionType | null>(null);
            
            
            Severity: Minor
            Found in packages/devtools-ui/src/components/package-item.tsx - About 2 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 createInquirerUI has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const createInquirerUI = (uiGroup: UIGroup) => {
              let maxNameLength = 0;
              let maxFromLength = 0;
            
              [uiGroup.patch, uiGroup.minor, uiGroup.major].forEach((group) => {
            Severity: Major
            Found in packages/cli/src/commands/update/interactive/index.ts - About 2 hrs to fix

              Function useNotificationProvider has 68 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const useNotificationProvider = (): NotificationProvider => {
                const { closeSnackbar, enqueueSnackbar } = useSnackbar();
              
                const notificationProvider: NotificationProvider = {
                  open: ({
              Severity: Major
              Found in packages/mui/src/providers/notificationProvider/index.tsx - About 2 hrs to fix

                Function resolver has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async (recordItemId: BaseKey | undefined) => {
                      const dataProviderName =
                        dataProviderFromResource(resource) ??
                        pickDataProvider(resource?.name, undefined, resources);
                      const dp = dataProvider(dataProviderName);
                Severity: Major
                Found in packages/inferencer/src/use-infer-fetch/index.tsx - About 2 hrs to fix

                  Function authProvider has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const authProvider = (API_URL: string): AuthProvider => {
                    const axiosInstance = axios.create();
                  
                    axiosInstance.interceptors.response.use(
                      (response) => {
                  Severity: Major
                  Found in packages/medusa/src/authProvider/index.ts - About 2 hrs to fix

                    Identical blocks of code found in 4 locations. Consider refactoring.
                    Open

                          {
                            group: "Pages",
                            label: "ErrorPage",
                            message: `
                                    **\`Info:\`**
                    Severity: Major
                    Found in packages/chakra-ui/refine.config.js and 3 other locations - About 2 hrs to fix
                    packages/antd/refine.config.js on lines 287..314
                    packages/mantine/refine.config.js on lines 232..259
                    packages/mui/refine.config.js on lines 142..169

                    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 88.

                    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

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language