pankod/refine

View on GitHub

Showing 580 of 800 total issues

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

export const useNotificationProvider = (): NotificationProvider => {
  const activeNotifications: string[] = [];

  const isNotificationActive = (key?: string) => {
    return activeNotifications.includes(key as string);
Severity: Major
Found in packages/mantine/src/providers/notificationProvider.tsx - About 5 hrs to fix

    Function checkPackage has 147 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const checkPackage = (code = "") => {
      const set = new Set<string>();
    
      const hasAntd =
        code.includes("@refinedev/antd") ||
    Severity: Major
    Found in packages/live-previews/src/utils/check-package.ts - About 5 hrs to fix

      Function fixDeprecatedUseTableProps has 146 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const fixDeprecatedUseTableProps = (j: JSCodeshift, source: Collection) => {
        const willCheckImports = ["useTable", "useDataGrid"];
      
        willCheckImports.forEach((hook) => {
          const useTableHooks = source.find(j.CallExpression, {
      Severity: Major
      Found in packages/codemod/src/transformations/v4/fix-v4-deprecations.ts - About 5 hrs to fix

        Function OnboardingForm has 145 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const OnboardingForm = () => {
          const [loading, setLoading] = React.useState(false);
          const { handleSubmit, control, setValue, setError, formState } =
            useForm<MeUpdateVariables>({
              defaultValues: {
        Severity: Major
        Found in packages/devtools-ui/src/pages/onboarding.tsx - About 5 hrs to fix

          Function DataProvider has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

          export const DataProvider = (
            apiUrl: string,
            httpClient: AxiosInstance = axiosInstance,
          ): Required<IDataProvider> => ({
            getList: async ({ resource, pagination, filters, sorters, meta }) => {
          Severity: Minor
          Found in packages/strapi-v4/src/dataProvider.ts - About 5 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 ConfigSuccessPage has 140 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ConfigSuccessPage: React.FC = () => {
            const isTablet = useMediaQuery("(max-width: 1010px)");
            const isMobile = useMediaQuery("(max-width: 650px)");
          
            const getGridTemplateColumns = () => {
          Severity: Major
          Found in packages/core/src/components/pages/config-success/index.tsx - About 5 hrs to fix

            Function renderRelationFields has 133 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const renderRelationFields = (field: InferField) => {
                if (field.relation && field.resource) {
                  const variableName = getVariableName(field.key, "Data");
                  const variableIsLoading = getVariableName(field.key, "IsLoading");
            
            
            Severity: Major
            Found in packages/inferencer/src/inferencers/mui/show.tsx - About 5 hrs to fix

              Function useExport has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

              export const useExport = <
                TData extends BaseRecord = BaseRecord,
                TVariables = any,
              >({
                resourceName,
              Severity: Minor
              Found in packages/core/src/hooks/export/index.ts - About 5 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 transformer has 127 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default async function transformer(file: FileInfo, api: API) {
                const j = api.jscodeshift;
                const source = j(file.source);
              
                const hasRefineElement =
              Severity: Major
              Found in packages/cli/src/transformers/integrations/react-router.ts - About 5 hrs to fix

                Function Header has 127 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const Header = () => {
                  const [connectedApp, setConnectedApp] = React.useState<string | null>(null);
                  const { ws } = React.useContext(DevToolsContext);
                
                  const fetchConnectedApp = React.useCallback(async () => {
                Severity: Major
                Found in packages/devtools-ui/src/components/header.tsx - About 5 hrs to fix

                  Function renderRelationFields has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const renderRelationFields = (field: InferField) => {
                      if (field.relation && field.resource) {
                        const variableName = getVariableName(field.key, "Data");
                        const variableIsLoading = getVariableName(field.key, "IsLoading");
                  
                  
                  Severity: Major
                  Found in packages/inferencer/src/inferencers/headless/show.tsx - About 5 hrs to fix

                    Function renderRelationFields has 121 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const renderRelationFields = (field: InferField) => {
                        if (field.relation && field.resource) {
                          const variableName = getVariableName(field.key, "Data");
                          const variableIsLoading = getVariableName(field.key, "IsLoading");
                    
                    
                    Severity: Major
                    Found in packages/inferencer/src/inferencers/mantine/show.tsx - About 4 hrs to fix

                      Function serveApi has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const serveApi = (app: Express, db: Data) => {
                        app.use("/api", json());
                      
                        app.get("/api/connected-app", (_, res) => {
                          res.json({ url: db.connectedApp });
                      Severity: Major
                      Found in packages/devtools-server/src/serve-api.ts - About 4 hrs to fix

                        Function renderRelationFields has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          const renderRelationFields = (field: InferField) => {
                            if (field.relation && field.resource) {
                              const variableName = getVariableName(field.key, "Data");
                              const variableIsLoading = getVariableName(field.key, "IsLoading");
                        
                        
                        Severity: Major
                        Found in packages/inferencer/src/inferencers/chakra-ui/show.tsx - About 4 hrs to fix

                          Function DevtoolsPanel has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              : () => {
                                  const [browser, setBrowser] = React.useState<boolean>(false);
                                  const [visible, setVisible] = React.useState(false);
                                  const [placement] = React.useState<Placement>("bottom");
                                  const { httpUrl, ws } = React.useContext(DevToolsContext);
                          Severity: Major
                          Found in packages/devtools/src/panel.tsx - About 4 hrs to fix

                            Function renderRelationFields has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const renderRelationFields = (field: InferField) => {
                                if (field.relation && field.resource) {
                                  const variableName = `${getVariableName(field.key, "Data")}?.data`;
                            
                                  if (Array.isArray(field.accessor)) {
                            Severity: Major
                            Found in packages/inferencer/src/inferencers/headless/list.tsx - About 4 hrs to fix

                              Function dataProvider has 117 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const dataProvider = (
                                apiKey: string,
                                baseId: string,
                                airtableClient?: AirtableBase,
                              ): Required<DataProvider> => {
                              Severity: Major
                              Found in packages/airtable/src/dataProvider.ts - About 4 hrs to fix

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

                                export default async function transformer(file: FileInfo, api: API) {
                                  const j = api.jscodeshift;
                                  const source = j(file.source);
                                
                                  const refineElement = source.find(j.JSXElement, {
                                Severity: Major
                                Found in packages/cli/src/transformers/integrations/ant-design.ts - About 4 hrs to fix

                                  Function runTests has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  const runTests = async () => {
                                    const examplesToRun = getProjectsWithE2E();
                                  
                                    if (examplesToRun.length === 0) {
                                      return { success: true, empty: true };
                                  Severity: Minor
                                  Found in .github/workflows/scripts/e2e-examples.js - About 4 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 a Cognitive Complexity of 31 (exceeds 5 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: Minor
                                  Found in packages/core/src/definitions/helpers/keys/index.ts - About 4 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language