pankod/refine

View on GitHub

Showing 812 of 823 total issues

Avoid deeply nested control flow statements.
Open

                          if (Array.isArray(field.relationInfer.accessor)) {
                            console.log(
                              "@refinedev/inferencer: Inferencer failed to render this field",
                              {
                                key: field.key,
Severity: Major
Found in packages/inferencer/src/inferencers/mui/show.tsx - About 45 mins to fix

    Function Status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const Status = ({ activity }: { activity: Activity }) => {
      const status = activity.status;
    
      const dataUpdateCount =
        activity.type === "query" ? activity.state.dataUpdateCount : 0;
    Severity: Minor
    Found in packages/devtools-ui/src/components/status.tsx - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

              if (namedImports.includes("default as")) {
                const scopedImportName = packageName.match(regexMatch[1])?.[1];
                namedImports = namedImports.replace(
                  "default as",
                  `${scopedImportName} as`,
    Severity: Major
    Found in packages/live-previews/src/utils/replace-imports.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                if (Array.isArray(field.relationInfer.accessor)) {
                                  console.log(
                                    "@refinedev/inferencer: Inferencer failed to render this field",
                                    {
                                      key: field.key,
      Severity: Major
      Found in packages/inferencer/src/inferencers/chakra-ui/show.tsx - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    for (const response of item.response) {
                      ids.push(response.id);
                    }
        Severity: Major
        Found in packages/strapi/src/helpers/normalize.ts - About 45 mins to fix

          Function FeedItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const FeedItem = ({ item }: Props) => {
            const isNew = dayjs().diff(dayjs(item.date), "day") <= 3;
            const isFeatured = item.featured;
          
            return (
          Severity: Minor
          Found in packages/devtools-ui/src/components/feed-item.tsx - About 45 mins 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 Packages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Packages = () => {
            const ref = React.useRef<FireworksHandlers>(null);
            const [packages, setPackages] = React.useState<PackageType[]>([]);
            const [visible, setVisible] = React.useState(false);
            const [outdatedPackages, setOutdatedPackages] = React.useState<string[]>([]);
          Severity: Minor
          Found in packages/devtools-ui/src/components/packages.tsx - About 45 mins 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 authProvider has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const authProvider = (API_URL: string): AuthProvider => {
            const axiosInstance = axios.create();
          
            axiosInstance.interceptors.response.use(
              (response) => {
          Severity: Minor
          Found in packages/medusa/src/authProvider/index.ts - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                      for (const response of item.response) {
                        ids.push(response.id);
                      }
          Severity: Major
          Found in packages/strapi-v4/src/helpers/normalize.ts - About 45 mins to fix

            Function liveProvider has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const liveProvider = (client: Client): LiveProvider => {
              const subscribeToResource = (
                client: Client,
                callback: Function,
                params: any,
            Severity: Minor
            Found in packages/nestjs-query/src/liveProvider/index.ts - About 45 mins 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 LoginPage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const LoginPage: React.FC<LoginProps> = ({
              providers,
              registerLink,
              forgotPasswordLink,
              rememberMe,
            Severity: Minor
            Found in packages/core/src/components/pages/auth/components/login/index.tsx - About 45 mins 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 useButtonCanAccess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const useButtonCanAccess = (
              props: ButtonCanAccessProps,
            ): ButtonCanAccessValues => {
              const translate = useTranslate();
              const accessControlContext = React.useContext(AccessControlContext);
            Severity: Minor
            Found in packages/core/src/hooks/button/button-can-access/index.tsx - About 45 mins 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 useCanWithoutCache has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const useCanWithoutCache = (): IAccessControlContext => {
              const { can: canFromContext } = React.useContext(AccessControlContext);
            
              const can = React.useMemo(() => {
                if (!canFromContext) {
            Severity: Minor
            Found in packages/core/src/hooks/accessControl/useCanWithoutCache.ts - About 45 mins 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 RegisterPage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const RegisterPage: React.FC<RegisterProps> = ({
              providers,
              loginLink,
              wrapperProps,
              contentProps,
            Severity: Minor
            Found in packages/core/src/components/pages/auth/components/register/index.tsx - About 45 mins 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

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

            export const ListButton: React.FC<ListButtonProps> = ({
              resource: resourceNameFromProps,
              resourceNameOrRouteName,
              hideText = false,
              accessControl,
            Severity: Major
            Found in packages/chakra-ui/src/components/buttons/list/index.tsx and 5 other locations - About 45 mins to fix
            packages/chakra-ui/src/components/buttons/create/index.tsx on lines 12..76
            packages/mantine/src/components/buttons/create/index.tsx on lines 13..85
            packages/mantine/src/components/buttons/list/index.tsx on lines 20..88
            packages/mui/src/components/buttons/create/index.tsx on lines 20..77
            packages/mui/src/components/buttons/list/index.tsx on lines 20..74

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

            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 6 locations. Consider refactoring.
            Open

            export const ListButton: React.FC<ListButtonProps> = ({
              resource: resourceNameFromProps,
              resourceNameOrRouteName,
              hideText = false,
              accessControl,
            Severity: Major
            Found in packages/mui/src/components/buttons/list/index.tsx and 5 other locations - About 45 mins to fix
            packages/chakra-ui/src/components/buttons/create/index.tsx on lines 12..76
            packages/chakra-ui/src/components/buttons/list/index.tsx on lines 19..80
            packages/mantine/src/components/buttons/create/index.tsx on lines 13..85
            packages/mantine/src/components/buttons/list/index.tsx on lines 20..88
            packages/mui/src/components/buttons/create/index.tsx on lines 20..77

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

            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 pickMatchedRoute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const pickMatchedRoute = (
              routes: ResourceActionRoute[],
            ): ResourceActionRoute | undefined => {
              // these routes are all matched, we should pick the least parametrized one
            
            
            Severity: Minor
            Found in packages/core/src/definitions/helpers/router/pick-matched-route.ts - About 45 mins 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

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

              const waitForLoading = () => {
                cy.contains(/loading/).should("not.exist");
                cy.get('[type="submit"]').should("not.be.disabled");
              };
            Severity: Minor
            Found in cypress/e2e/form-react-hook-form-use-modal-form/all.cy.ts and 1 other location - About 45 mins to fix
            cypress/e2e/form-react-hook-form-use-form/all.cy.ts on lines 43..46

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

            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

                      const customTransformedFields = fieldTransformer
                        ? transformed.flatMap((field) => {
                            const result = fieldTransformer(field);
            
                            return result ? [result] : [];
            Severity: Minor
            Found in packages/inferencer/src/create-inferencer/index.tsx and 1 other location - About 45 mins to fix
            packages/inferencer/src/create-inferencer/index.tsx on lines 100..106

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

            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 6 locations. Consider refactoring.
            Open

            export const CreateButton: React.FC<CreateButtonProps> = ({
              resource: resourceNameFromProps,
              resourceNameOrRouteName,
              hideText = false,
              accessControl,
            Severity: Major
            Found in packages/mantine/src/components/buttons/create/index.tsx and 5 other locations - About 45 mins to fix
            packages/chakra-ui/src/components/buttons/create/index.tsx on lines 12..76
            packages/chakra-ui/src/components/buttons/list/index.tsx on lines 19..80
            packages/mantine/src/components/buttons/list/index.tsx on lines 20..88
            packages/mui/src/components/buttons/create/index.tsx on lines 20..77
            packages/mui/src/components/buttons/list/index.tsx on lines 20..74

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

            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