pankod/refine

View on GitHub

Showing 208 of 232 total issues

Function Sider has 362 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Sider: React.FC = () => {
    const [collapsed, setCollapsed] = useState(false);
    const [opened, setOpened] = useState(false);

    const drawerWidth = () => {
Severity: Major
Found in packages/mui/src/components/layout/sider/index.tsx - About 1 day to fix

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

    export const generateFilters: any = (filters?: CrudFilters) => {
        if (!filters) {
            return undefined;
        }
    
    
    Severity: Major
    Found in packages/nhost/src/index.ts and 1 other location - About 1 day to fix
    packages/hasura/src/index.ts on lines 69..107

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

    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

    export const generateFilters: any = (filters?: CrudFilters) => {
        if (!filters) {
            return undefined;
        }
    
    
    Severity: Major
    Found in packages/hasura/src/index.ts and 1 other location - About 1 day to fix
    packages/nhost/src/index.ts on lines 70..108

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

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

    const dataProvider = (client: NhostClient): DataProvider => {
        client;
        return {
            getOne: async ({ resource, id, metaData }) => {
                const operation = `${metaData?.operation ?? resource}_by_pk`;
    Severity: Major
    Found in packages/nhost/src/index.ts - About 1 day to fix

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

      const generateFilter = (filters?: CrudFilters) => {
          const queryFilters: { [key: string]: any } = {};
      
          if (filters) {
              filters.map((filter) => {
      Severity: Major
      Found in packages/strapi-graphql/src/index.ts and 1 other location - About 1 day to fix
      packages/graphql/src/index.ts on lines 19..48

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

      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 generateFilter = (filters?: CrudFilters) => {
          const queryFilters: { [key: string]: any } = {};
      
          if (filters) {
              filters.map((filter) => {
      Severity: Major
      Found in packages/graphql/src/index.ts and 1 other location - About 1 day to fix
      packages/strapi-graphql/src/index.ts on lines 19..48

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

      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

      export const getValueProps = (data: any, imageUrl: string) => {
          if (!data) {
              return { fileList: [] };
          }
      
      
      Severity: Major
      Found in packages/strapi/src/helpers/normalize.ts and 1 other location - About 1 day to fix
      packages/strapi-v4/src/helpers/normalize.ts on lines 1..27

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

      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

      export const getValueProps = (data: any, imageUrl: string) => {
          if (!data) {
              return { fileList: [] };
          }
      
      
      Severity: Major
      Found in packages/strapi-v4/src/helpers/normalize.ts and 1 other location - About 1 day to fix
      packages/strapi/src/helpers/normalize.ts on lines 1..27

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

      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

      export const mediaUploadMapper = (params: any) => {
          Object.keys(params).map((item) => {
              if (params[item]) {
                  const param = params[item].fileList;
                  const isMediaField = Array.isArray(param);
      Severity: Major
      Found in packages/strapi-v4/src/helpers/normalize.ts and 1 other location - About 7 hrs to fix
      packages/strapi/src/helpers/normalize.ts on lines 29..50

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

      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

      export const mediaUploadMapper = (params: any) => {
          Object.keys(params).map((item) => {
              if (params[item]) {
                  const param = params[item].fileList;
                  const isMediaField = Array.isArray(param);
      Severity: Major
      Found in packages/strapi/src/helpers/normalize.ts and 1 other location - About 7 hrs to fix
      packages/strapi-v4/src/helpers/normalize.ts on lines 29..50

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

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

      export const LoginPage: React.FC = () => {
          const {
              register,
              handleSubmit,
              formState: { errors },
      Severity: Major
      Found in packages/mui/src/components/pages/login/index.tsx - About 7 hrs to fix

        Function dataProvider has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

        const dataProvider = (supabaseClient: SupabaseClient): DataProvider => {
            return {
                getList: async ({
                    resource,
                    hasPagination = true,
        Severity: Minor
        Found in packages/supabase/src/index.ts - About 7 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 dataProvider has 164 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const dataProvider = (appwriteClient: Appwrite): DataProvider => {
            return {
                //TODO: Fix typing
                getList: async ({
                    resource,
        Severity: Major
        Found in packages/appwrite/src/index.ts - About 6 hrs to fix

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

          export const AuthHelper = (apiUrl: string) => ({
              login: async (identifier: string, password: string) => {
                  const url = `${apiUrl}/auth/local`;
          
                  return await axios.post<ILoginResponse>(url, {
          Severity: Major
          Found in packages/strapi/src/helpers/auth.ts and 1 other location - About 5 hrs to fix
          packages/strapi-v4/src/helpers/auth.ts on lines 27..43

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

          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

          export const AuthHelper = (apiUrl: string) => ({
              login: async (identifier: string, password: string) => {
                  const url = `${apiUrl}/auth/local`;
          
                  return await axios.post<ILoginResponse>(url, {
          Severity: Major
          Found in packages/strapi-v4/src/helpers/auth.ts and 1 other location - About 5 hrs to fix
          packages/strapi/src/helpers/auth.ts on lines 27..43

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

          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

          export const file2Base64 = (file: any): Promise<string> => {
              return new Promise((resolve, reject) => {
                  const reader = new FileReader();
          
                  const resultHandler = () => {
          Severity: Major
          Found in packages/core/src/definitions/upload/file2Base64/index.ts and 1 other location - About 5 hrs to fix
          packages/antd/src/definitions/upload/index.ts on lines 9..29

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

          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

          export function file2Base64(file: UploadFile): Promise<string> {
              return new Promise((resolve, reject) => {
                  const reader = new FileReader();
          
                  const resultHandler = () => {
          Severity: Major
          Found in packages/antd/src/definitions/upload/index.ts and 1 other location - About 5 hrs to fix
          packages/core/src/definitions/upload/file2Base64/index.ts on lines 1..21

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

          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 useTable has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          export const useTable = <
              TData extends BaseRecord = BaseRecord,
              TError extends HttpError = HttpError,
              TSearchVariables = unknown,
          >(
          Severity: Minor
          Found in packages/antd/src/hooks/table/useTable/useTable.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 Sider has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Sider: React.FC = () => {
              const [collapsed, setCollapsed] = useState(false);
              const [opened, setOpened] = useState(false);
          
              const drawerWidth = () => {
          Severity: Minor
          Found in packages/mui/src/components/layout/sider/index.tsx - 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 ResourceComponentWrapper has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          export const ResourceComponentWrapper: React.FC<{ route: string }> = ({
              route,
          }) => {
              const { catchAll } = useRefineContext();
              const { useParams } = useRouterContext();
          Severity: Minor
          Found in packages/react-location/src/resourceComponent.tsx - 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

          Severity
          Category
          Status
          Source
          Language