pankod/refine

View on GitHub

Showing 963 of 987 total issues

Function serveApi has 115 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 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/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

    Function separateImports has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function separateImports(payload: {
      j: JSCodeshift;
      source: Collection<any>;
      imports: string[];
      renameImports: { [key: string]: string };
    Severity: Major
    Found in packages/codemod/src/helpers/separate-imports.ts - About 4 hrs to fix

      Function Create has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const Create: React.FC<CreateProps> = (props) => {
        const {
          children,
          saveButtonProps: saveButtonPropsFromProps,
          isLoading,
      Severity: Major
      Found in packages/mantine/src/components/crud/create/index.tsx - About 4 hrs to fix

        Function ConfigErrorPage has 113 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const ConfigErrorPage = () => {
          return (
            <div
              style={{
                position: "fixed",
        Severity: Major
        Found in packages/core/src/components/pages/config-error/index.tsx - About 4 hrs to fix

          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/antd/create.tsx and 1 other location - About 4 hrs to fix
          packages/inferencer/src/inferencers/antd/edit.tsx on lines 421..441

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

          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/antd/edit.tsx and 1 other location - About 4 hrs to fix
          packages/inferencer/src/inferencers/antd/create.tsx on lines 335..355

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

          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 renderRelationFields has 112 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`;
                const variableIsLoading = getVariableName(field.key, "IsLoading");
          
          
          Severity: Major
          Found in packages/inferencer/src/inferencers/mui/list.tsx - About 4 hrs to fix

            Function renderRelationFields has 111 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/antd/show.tsx - About 4 hrs to fix

              Function LoginForm has 111 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const LoginForm = (props: { className?: string }) => {
                const { ws } = React.useContext(DevToolsContext);
                const [searchParams] = useSearchParams();
                const [flowData, setFlowData] = React.useState<LoginFlow | null>(null);
              
              
              Severity: Major
              Found in packages/devtools-ui/src/pages/login.tsx - About 4 hrs to fix

                Function useSimpleList has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                Open

                export const useSimpleList = <
                  TQueryFnData extends BaseRecord = BaseRecord,
                  TError extends HttpError = HttpError,
                  TSearchVariables = unknown,
                  TData extends BaseRecord = TQueryFnData,
                Severity: Minor
                Found in packages/antd/src/hooks/list/useSimpleList/useSimpleList.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

                Function useModalForm has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                Open

                export const useModalForm = <
                  TQueryFnData extends BaseRecord = BaseRecord,
                  TError extends HttpError = HttpError,
                  TVariables extends FieldValues = FieldValues,
                  TContext extends object = {},
                Severity: Minor
                Found in packages/react-hook-form/src/useModalForm/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

                Function renderRelationFields has 108 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/chakra-ui/list.tsx - About 4 hrs to fix

                  Function reorderImports has 108 lines of code (exceeds 25 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: Major
                  Found in packages/cli/src/utils/swizzle/import.ts - About 4 hrs to fix

                    Function renderRelationFields has 107 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/mantine/list.tsx - About 4 hrs to fix

                      Function List has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const List: React.FC<ListProps> = (props) => {
                        const {
                          canCreate,
                          children,
                          createButtonProps: createButtonPropsFromProps,
                      Severity: Major
                      Found in packages/chakra-ui/src/components/crud/list/index.tsx - About 4 hrs to fix

                        Function useModalForm has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const useModalForm = <
                          TQueryFnData extends BaseRecord = BaseRecord,
                          TError extends HttpError = HttpError,
                          TVariables = {},
                          TData extends BaseRecord = TQueryFnData,
                        Severity: Minor
                        Found in packages/antd/src/hooks/form/useModalForm/useModalForm.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

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

                        export const Create: React.FC<CreateProps> = (props) => {
                          const {
                            children,
                            saveButtonProps: saveButtonPropsFromProps,
                            isLoading,
                        Severity: Minor
                        Found in packages/chakra-ui/src/components/crud/create/index.tsx - 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 checkPackage has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const checkPackage = (code = "") => {
                          const set = new Set<string>();
                        
                          const hasAntd =
                            code.includes("@refinedev/antd") ||
                        Severity: Minor
                        Found in packages/live-previews/src/utils/check-package.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