pankod/refine

View on GitHub

Showing 959 of 983 total issues

Function transformer has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function transformer(file: FileInfo, api: API, options: any) {
  const j = api.jscodeshift;
  const source = j(file.source);

  const rootElement = source.find(j.JSXElement, {
Severity: Major
Found in packages/cli/src/transformers/resource.ts - About 3 hrs to fix

    Function useResource has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useResource(
      args?: UseResourceLegacyProps | UseResourceParam,
    ): UseResourceReturnType {
      const { resources } = useContext(ResourceContext);
    
    
    Severity: Major
    Found in packages/core/src/hooks/resource/useResource/index.ts - About 3 hrs to fix

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

          <Anchor
            component={LinkComponent as any}
            to={to}
            replace={false}
            onClick={(e: React.PointerEvent<HTMLButtonElement>) => {
      Severity: Major
      Found in packages/mantine/src/components/buttons/edit/index.tsx and 4 other locations - About 3 hrs to fix
      packages/mantine/src/components/buttons/clone/index.tsx on lines 45..89
      packages/mantine/src/components/buttons/create/index.tsx on lines 37..83
      packages/mantine/src/components/buttons/list/index.tsx on lines 42..86
      packages/mantine/src/components/buttons/show/index.tsx on lines 44..87

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

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

          <Anchor
            component={LinkComponent as any}
            to={to}
            replace={false}
            onClick={(e: React.PointerEvent<HTMLButtonElement>) => {
      Severity: Major
      Found in packages/mantine/src/components/buttons/list/index.tsx and 4 other locations - About 3 hrs to fix
      packages/mantine/src/components/buttons/clone/index.tsx on lines 45..89
      packages/mantine/src/components/buttons/create/index.tsx on lines 37..83
      packages/mantine/src/components/buttons/edit/index.tsx on lines 44..88
      packages/mantine/src/components/buttons/show/index.tsx on lines 44..87

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

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

          <Anchor
            component={LinkComponent as any}
            to={to}
            replace={false}
            onClick={(e: React.PointerEvent<HTMLButtonElement>) => {
      Severity: Major
      Found in packages/mantine/src/components/buttons/clone/index.tsx and 4 other locations - About 3 hrs to fix
      packages/mantine/src/components/buttons/create/index.tsx on lines 37..83
      packages/mantine/src/components/buttons/edit/index.tsx on lines 44..88
      packages/mantine/src/components/buttons/list/index.tsx on lines 42..86
      packages/mantine/src/components/buttons/show/index.tsx on lines 44..87

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

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

          <Anchor
            component={LinkComponent as any}
            to={to}
            replace={false}
            onClick={(e: React.PointerEvent<HTMLButtonElement>) => {
      Severity: Major
      Found in packages/mantine/src/components/buttons/show/index.tsx and 4 other locations - About 3 hrs to fix
      packages/mantine/src/components/buttons/clone/index.tsx on lines 45..89
      packages/mantine/src/components/buttons/create/index.tsx on lines 37..83
      packages/mantine/src/components/buttons/edit/index.tsx on lines 44..88
      packages/mantine/src/components/buttons/list/index.tsx on lines 42..86

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

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

          <Anchor
            component={LinkComponent as any}
            to={to}
            replace={false}
            onClick={(e: React.PointerEvent<HTMLButtonElement>) => {
      Severity: Major
      Found in packages/mantine/src/components/buttons/create/index.tsx and 4 other locations - About 3 hrs to fix
      packages/mantine/src/components/buttons/clone/index.tsx on lines 45..89
      packages/mantine/src/components/buttons/edit/index.tsx on lines 44..88
      packages/mantine/src/components/buttons/list/index.tsx on lines 42..86
      packages/mantine/src/components/buttons/show/index.tsx on lines 44..87

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

      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 bootstrap has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const bootstrap = () => {
        const packageJson = JSON.parse(
          readFileSync(`${__dirname}/../package.json`, "utf8"),
        );
      
      
      Severity: Major
      Found in packages/create-refine-app/src/index.ts - About 3 hrs to fix

        Function action has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        const action = async (_options: OptionValues) => {
          inquirer.registerPrompt("autocomplete", inquirerAutoCompletePrompt);
        
          const installedPackages = await getInstalledRefinePackagesFromNodeModules();
        
        
        Severity: Minor
        Found in packages/cli/src/commands/swizzle/index.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

        Function useDataGrid has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        export function useDataGrid<
          TQueryFnData extends BaseRecord = BaseRecord,
          TError extends HttpError = HttpError,
          TSearchVariables = unknown,
          TData extends BaseRecord = TQueryFnData,
        Severity: Minor
        Found in packages/mui/src/hooks/useDataGrid/index.ts - 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

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

          const renderedFields: Array<string | undefined> = fields.map((field) => {
            switch (field?.type) {
              case "text":
              case "number":
              case "email":
        Severity: Major
        Found in packages/inferencer/src/inferencers/headless/create.tsx and 1 other location - About 3 hrs to fix
        packages/inferencer/src/inferencers/headless/edit.tsx on lines 324..340

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

        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 renderedFields: Array<string | undefined> = fields.map((field) => {
            switch (field?.type) {
              case "text":
              case "number":
              case "email":
        Severity: Major
        Found in packages/inferencer/src/inferencers/headless/edit.tsx and 1 other location - About 3 hrs to fix
        packages/inferencer/src/inferencers/headless/create.tsx on lines 246..262

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

        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 objectInfer has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const objectInfer: FieldInferencer = (
          key,
          value,
          record,
          infer,
        Severity: Major
        Found in packages/inferencer/src/field-inferencers/object.ts - About 3 hrs to fix

          Function ErrorComponent has 80 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ErrorComponent: React.FC<RefineErrorPageProps> = () => {
            const [errorMessage, setErrorMessage] = useState<string>();
            const translate = useTranslate();
            const { push } = useNavigation();
            const go = useGo();
          Severity: Major
          Found in packages/mantine/src/components/pages/error/index.tsx - About 3 hrs to fix

            Function Sidebar has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const Sidebar = () => {
              const itemContainerRef = React.useRef<HTMLDivElement>(null);
              const { pathname } = useLocation();
            
              const [itemsToRender, setItemsToRender] = React.useState<typeof items>([]);
            Severity: Major
            Found in packages/devtools-ui/src/components/sidebar.tsx - About 3 hrs to fix

              Function liveProvider has 80 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const liveProvider = (
                supabaseClient: SupabaseClient<any, any, any>,
              ): LiveProvider => {
                return {
                  subscribe: ({
              Severity: Major
              Found in packages/supabase/src/liveProvider/index.ts - About 3 hrs to fix

                Function DevToolsApp has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const DevToolsApp = () => {
                  return (
                    <DevToolsContextProvider __devtools>
                      <ReloadOnChanges />
                      <BrowserRouter>
                Severity: Major
                Found in packages/devtools-ui/src/devtools.tsx - About 3 hrs to fix

                  Function FeatureSlideMobile has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const FeatureSlideMobile = (props: { className?: string }) => {
                    return (
                      <div
                        className={clsx(
                          "re-max-w-[640px]",
                  Severity: Major
                  Found in packages/devtools-ui/src/components/feature-slide.tsx - About 3 hrs to fix

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

                    export const Create: React.FC<CreateProps> = ({
                      title,
                      children,
                      saveButtonProps: saveButtonPropsFromProps,
                      resource: resourceFromProps,
                    Severity: Minor
                    Found in packages/mui/src/components/crud/create/index.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

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

                    export const transformCrudOperatorToMuiOperator = (
                      operator: CrudOperators,
                      columnType?: string,
                    ): string => {
                      switch (columnType) {
                    Severity: Major
                    Found in packages/mui/src/definitions/dataGrid/index.ts - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language