pankod/refine

View on GitHub

Showing 756 of 987 total issues

Function useResourceParams has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function useResourceParams(props?: Props): ResourceParams {
  const { select, identifier: inferredIdentifier } = useResource();
  const resourceToCheck = props?.resource ?? inferredIdentifier;
  const { identifier = undefined, resource = undefined } = resourceToCheck
    ? select(resourceToCheck, true)
Severity: Minor
Found in packages/core/src/hooks/use-resource-params/index.ts - About 1 hr 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 useLog has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const useLog = <
  TLogData,
  TLogRenameData extends LogRenameData = LogRenameData,
>({
  logMutationOptions,
Severity: Minor
Found in packages/core/src/hooks/auditLog/useLog/index.ts - About 1 hr 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 LegacyAuthContextProvider has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

> = ({ children, isProvided, ...authOperations }) => {
  const { replace } = useNavigation();

  const loginFunc = async (params: any) => {
    try {
Severity: Minor
Found in packages/core/src/contexts/auth/index.tsx - About 1 hr 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 useDataProvider has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const useDataProvider = (): ((
  /**
   * The name of the `data provider` you want to access
   */
  dataProviderName?: string,
Severity: Minor
Found in packages/core/src/hooks/data/useDataProvider.tsx - About 1 hr 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 useOne has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const useOne = <
  TQueryFnData extends BaseRecord = BaseRecord,
  TError extends HttpError = HttpError,
  TData extends BaseRecord = TQueryFnData,
>({
Severity: Minor
Found in packages/core/src/hooks/data/useOne.ts - About 1 hr 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 printImports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const printImports = (imports: Array<ImportElement>) => {
  const byModule = imports.reduce(
    (acc, [element, module, isDefault]) => {
      if (!acc[module]) {
        acc[module] = [] as Array<
Severity: Minor
Found in packages/inferencer/src/utilities/print-imports/index.ts - About 1 hr to fix

    Function emailFields has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const emailFields = (field: InferField) => {
        if (field.type === "email") {
          imports.push(
            ["TagField", "@refinedev/antd"],
            ["EmailField", "@refinedev/antd"],
    Severity: Minor
    Found in packages/inferencer/src/inferencers/antd/list.tsx - About 1 hr to fix

      Function urlFields has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const urlFields = (field: InferField) => {
          if (field.type === "url") {
            imports.push(
              ["UrlField", "@refinedev/antd"],
              ["TagField", "@refinedev/antd"],
      Severity: Minor
      Found in packages/inferencer/src/inferencers/antd/list.tsx - About 1 hr to fix

        Function booleanFields has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const booleanFields = (field: InferField) => {
            if (field.type === "boolean") {
              if (field.multiple) {
                return undefined;
              }
        Severity: Minor
        Found in packages/inferencer/src/inferencers/headless/create.tsx - About 1 hr to fix

          Function printFiles has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const printFiles = () => {
              const chalks = [];
          
              chalks.push(chalk.dim(`File${files.length > 1 ? "s" : ""} created:`));
              chalks.push(
          Severity: Minor
          Found in packages/cli/src/components/swizzle-message/index.tsx - About 1 hr to fix

            Function useGo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const useGo = () => {
              const routerContext = useContext(RouterContext);
              const { select: resourceSelect } = useResource();
              const getToPath = useGetToPath();
            
            
            Severity: Minor
            Found in packages/core/src/hooks/router/use-go/index.tsx - About 1 hr to fix

              Function updatePromise has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      (resolve, reject) => {
                        const doMutation = () => {
                          dataProvider(
                            pickDataProvider(identifier, dataProviderName, resources),
                          )
              Severity: Minor
              Found in packages/core/src/hooks/data/useUpdate.ts - About 1 hr to fix

                Function useResourceParams has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function useResourceParams(props?: Props): ResourceParams {
                  const { select, identifier: inferredIdentifier } = useResource();
                  const resourceToCheck = props?.resource ?? inferredIdentifier;
                  const { identifier = undefined, resource = undefined } = resourceToCheck
                    ? select(resourceToCheck, true)
                Severity: Minor
                Found in packages/core/src/hooks/use-resource-params/index.ts - About 1 hr to fix

                  Function useGetToPath has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const useGetToPath = (): GetToPathFn => {
                    const routerType = useRouterType();
                    const { resource: resourceFromRoute, resources } = useResource();
                    const parsed = useParsed();
                  
                  
                  Severity: Minor
                  Found in packages/core/src/hooks/router/use-get-to-path/index.ts - About 1 hr to fix

                    Function deletePromise has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            (resolve, reject) => {
                              const doMutation = () => {
                                dataProvider(
                                  pickDataProvider(identifier, dataProviderName, resources),
                                )
                    Severity: Minor
                    Found in packages/core/src/hooks/data/useDelete.ts - About 1 hr to fix

                      Function queryKeys has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const queryKeys = (
                        resource?: string,
                        dataProviderName?: string,
                        meta?: MetaQuery,
                        /**
                      Severity: Minor
                      Found in packages/core/src/definitions/helpers/queryKeys/index.ts - About 1 hr to fix

                        Function assertDocumentTitle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const assertDocumentTitle = (resource: string, action?: IAction) => {
                          switch (action) {
                            case "list":
                              cy.document()
                                .its("title")
                        Severity: Minor
                        Found in cypress/support/commands/document-title-handler.ts - About 1 hr to fix

                          Function textFields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            const textFields = (field: InferField) => {
                              if (
                                field.type === "text" ||
                                field.type === "email" ||
                                field.type === "date" ||
                          Severity: Minor
                          Found in packages/inferencer/src/inferencers/mantine/create.tsx - About 1 hr to fix

                            Function relationHooksCode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                .map((field) => {
                                  if (field?.relation && !field.fieldable && field.resource) {
                                    imports.push(["useAutocomplete", "@refinedev/mui"]);
                                    let val = accessor(recordName, field.key, field.accessor, false);
                            
                            
                            Severity: Minor
                            Found in packages/inferencer/src/inferencers/mui/edit.tsx - About 1 hr to fix

                              Function generateFilter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const generateFilter = (filters?: CrudFilters) => {
                                let rawQuery = "";
                              
                                if (filters) {
                                  filters.map((filter) => {
                              Severity: Minor
                              Found in packages/strapi/src/dataProvider.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language