pankod/refine

View on GitHub

Showing 750 of 983 total issues

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

    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

            Function ErrorComponent has 66 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/chakra-ui/src/components/pages/error/index.tsx - About 2 hrs to fix

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

              export const ReadyPage: React.FC<RefineReadyPageProps> = () => {
                return (
                  <Box
                    p="4"
                    display="flex"
              Severity: Major
              Found in packages/chakra-ui/src/components/pages/ready/index.tsx - About 2 hrs to fix

                Function basicInputFields has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const basicInputFields = (field: InferField) => {
                    if (
                      field.type === "text" ||
                      field.type === "url" ||
                      field.type === "email" ||
                Severity: Major
                Found in packages/inferencer/src/inferencers/headless/create.tsx - About 2 hrs to fix

                  Function useInvalidate has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const useInvalidate = (): ((
                    props: UseInvalidateProp,
                  ) => Promise<void>) => {
                    const { resources } = useResource();
                    const queryClient = useQueryClient();
                  Severity: Major
                  Found in packages/core/src/hooks/invalidate/index.tsx - About 2 hrs to fix

                    Function getOperationFields has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const getOperationFields = (documentNode: DocumentNode) => {
                      const fieldLines: string[] = [];
                      let isInitialEnter = true;
                      let depth = 0;
                      let isNestedField = false;
                    Severity: Minor
                    Found in packages/graphql/src/utils/graphql.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 getOperationFields has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const getOperationFields = (documentNode: DocumentNode) => {
                      const fieldLines: string[] = [];
                      let isInitialEnter = true;
                      let depth = 0;
                      let isNestedField = false;
                    Severity: Minor
                    Found in packages/hasura/src/utils/graphql.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 useForm has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const useForm = <
                      TQueryFnData extends BaseRecord = BaseRecord,
                      TError extends HttpError = HttpError,
                      TVariables = Record<string, unknown>,
                      TTransformed = TVariables,
                    Severity: Minor
                    Found in packages/mantine/src/hooks/form/useForm/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 go has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                      go: () => {
                        const { push, replace, asPath: pathname } = useRouter();
                    
                        const fn = React.useCallback(
                          ({
                    Severity: Minor
                    Found in packages/nextjs-router/src/pages/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 basicToRelation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const basicToRelation: FieldTransformer = (
                      fields,
                      resources,
                      resource,
                      record,
                    Severity: Minor
                    Found in packages/inferencer/src/field-transformers/basic-to-relation.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 fixUseListHasPaginationToPaginationMode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const fixUseListHasPaginationToPaginationMode = (
                      j: JSCodeshift,
                      source: Collection,
                    ) => {
                      const useListHooks = source.find(j.CallExpression, {
                    Severity: Major
                    Found in packages/codemod/src/transformations/v4/fix-v4-deprecations.ts - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language