pankod/refine

View on GitHub

Showing 812 of 823 total issues

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

export const wrapChildren = (
  j: JSCodeshift,
  source: Collection,
  element: ASTPath<JSXElement>,
  wrapper: string,
Severity: Minor
Found in packages/cli/src/utils/codeshift/index.ts and 1 other location - About 35 mins to fix
packages/cli/src/utils/codeshift/index.ts on lines 11..41

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

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

  params?: {
    resource?: IResourceItem & { children?: ITreeMenu[] };
    id?: BaseKey;
    [key: string]: any;
  };
Severity: Minor
Found in packages/core/src/contexts/accessControl/types.ts and 1 other location - About 35 mins to fix
packages/core/src/components/canAccess/index.tsx on lines 10..14

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

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 isBasicArray =
    Array.isArray(value) &&
    value.every((v) => typeof v === "string" || typeof v === "number");
Severity: Minor
Found in packages/inferencer/src/field-inferencers/array.ts and 1 other location - About 35 mins to fix
packages/inferencer/src/field-inferencers/relation.ts on lines 8..10

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

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

export const relationInfer: FieldInferencer = (key, value) => {
  const isRelation = relationRegexp.test(key);
  const isBasicValue = typeof value === "string" || typeof value === "number";
  const isBasicArray =
    Array.isArray(value) &&
Severity: Minor
Found in packages/inferencer/src/field-inferencers/relation.ts - About 35 mins 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 liveProvider has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const liveProvider = (client: Client): LiveProvider => {
  return {
    subscribe: ({ callback, params }) => {
      const {
        resource,
Severity: Minor
Found in packages/hasura/src/liveProvider/index.ts - About 35 mins 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 ThemedTitleV2 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const ThemedTitleV2: React.FC<RefineLayoutThemedTitleProps> = ({
  collapsed,
  icon: iconFromProps,
  text: textFromProps,
  wrapperStyles = {},
Severity: Minor
Found in packages/mantine/src/components/themedLayoutV2/title/index.tsx - About 35 mins 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 generateNestedFilterQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const generateNestedFilterQuery = (
  filter: HasuraCrudFilter,
  namingConvention: NamingConvention = "hasura-default",
): BoolExp => {
  const { operator } = filter;
Severity: Minor
Found in packages/hasura/src/utils/generateFilters.ts - About 35 mins 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 pickMeta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const pickMeta = (
  identifier?: string,
  meta?: InferencerComponentProps["meta"],
  actions?: Action[],
) => {
Severity: Minor
Found in packages/inferencer/src/utilities/get-meta-props/index.ts - About 35 mins 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 addOrUpdateImports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const addOrUpdateImports = (
  j: JSCodeshift,
  source: Collection,
  importPath: string,
  importIdentifierNames: string[],
Severity: Minor
Found in packages/cli/src/utils/codeshift/index.ts - About 35 mins 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 Authenticated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const Authenticated = ({
  children,
  fallback,
}: {
  children: React.ReactNode;
Severity: Minor
Found in packages/devtools-ui/src/components/authenticated.tsx - About 35 mins 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 MonitorAppliedFilterGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const MonitorAppliedFilterGroup = ({ filters, onClear }: Props) => {
  const hasFilters =
    filters.hook.length > 0 ||
    filters.scope.length > 0 ||
    filters.status.length > 0 ||
Severity: Minor
Found in packages/devtools-ui/src/components/monitor-applied-filter-group.tsx - About 35 mins 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 ThemeProvider has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const ThemeProvider = ({
  children,
  theme,
}: {
  children?: React.ReactNode;
Severity: Minor
Found in packages/live-previews/src/scope/mui.tsx - About 35 mins 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 Select has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const Select = <TType extends "multiple" | "single">({
  type,
  options,
  placeholder,
  hint,
Severity: Minor
Found in packages/devtools-ui/src/components/select.tsx - About 35 mins 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 downloadAndExtract has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export async function downloadAndExtract({
  root,
  name,
  branch,
  repo,
Severity: Minor
Found in packages/create-refine-app/src/example/download-and-extract.ts - About 35 mins 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 Auth0Provider has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const Auth0Provider = ({ children }: { children: React.ReactNode }) => {
  const externalNavigator = React.useContext(ExternalNavigationContext);

  const [isAuthenticated, setIsAuthenticated] = React.useState(false);

Severity: Minor
Found in packages/live-previews/src/scope/auth0.tsx - About 35 mins 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 getDevtoolsUrlFromEnv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getDevtoolsUrlFromEnv = () => {
  const PORT_FROM_ENV =
    typeof __PROCESS_KEY__ !== "undefined" && "env" in __PROCESS_KEY__
      ? __PROCESS_ENV_REFINE_DEVTOOLS_PORT_KEY__ ||
        __PROCESS_ENV_NEXT_PUBLIC_REFINE_DEVTOOLS_PORT_KEY__ ||
Severity: Minor
Found in packages/devtools/src/utilities/get-devtools-url-from-env.ts - About 35 mins 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 getWantedWithPreferredWildcard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getWantedWithPreferredWildcard = (
  packageName: RefinePackageInstalledVersionData["name"],
  versionWanted: RefinePackageInstalledVersionData["wanted"],
): string => {
  const dependencies = getDependenciesWithVersion();
Severity: Minor
Found in packages/cli/src/commands/check-updates/index.tsx - About 35 mins 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 getDefaultActionPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getDefaultActionPath = (
  resourceName: string,
  action: Action,
  parentPrefix?: string,
): string => {
Severity: Minor
Found in packages/core/src/definitions/helpers/router/get-default-action-path.ts - About 35 mins 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 createResources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const createResources = async (
  params: { actions?: string; path?: string },
  resources: string[],
) => {
  const destinationPath =
Severity: Minor
Found in packages/cli/src/commands/add/sub-commands/resource/create-resources.ts - About 35 mins 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 Breadcrumb has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const Breadcrumb: React.FC<BreadcrumbProps> = ({
  breadcrumbProps,
  showHome = true,
  hideIcons = false,
  meta,
Severity: Minor
Found in packages/mui/src/components/breadcrumb/index.tsx - About 35 mins 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