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);
- Read upRead up
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);
- Read upRead up
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);
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();
- Read upRead up
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,
- Read upRead up
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);
- Read upRead up
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) => {
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: ({
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);
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) => {
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();
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"
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" ||
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();
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;
- Read upRead up
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;
- Read upRead up
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,
- Read upRead up
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(
({
- Read upRead up
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,
- Read upRead up
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, {