Showing 71 of 137 total issues
Function applyTabs
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applyTabs() {
const tabLinks: HTMLAnchorElement[] = Array.from(
document.querySelectorAll(".content-tabs li a")
);
const tabs: HTMLDivElement[] = Array.from(
Function DateTimeSelect
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function DateTimeSelect(props: DateTimeSelectProps) {
const { name, disabled, disableTime, onChange, value } = props;
const [timeString, setTimeString] = useState(timeToString(value));
Function Block
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Block(props: Props) {
const { block, errors, onChange, lang, dir, value } = props;
const handleChange = (
evt: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
Function Node
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export default function Node(props: Props) {
const { id, state, dispatch, dragging, onDragStart } = props;
const { dir, locale } = state;
const node = state.nodes[id];
const page = node.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 Grid
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export default function Grid(props: Props) {
const { primary, images, deleted, setDeleted } = props.state;
const containerRef = useRef();
const error = useToastStore((state) => state.error);
- 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 Dates
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Dates(props: Props) {
const { state, dispatch } = props;
const { datesEnabled, page } = state;
const toggleAllDay = () => {
Function ImageEditor
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ImageEditor(props: Props) {
const [cropState, dispatch, croppedImage] = useCrop(props.image);
const [locale, setLocale] = useState(props.locale);
const [localizations, setLocalizations] = useState({
caption: props.image.caption || {},
Function Image
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Image(props: Props) {
const imageSize = () => {
const { image, cropping, crop_width, crop_height } = props.cropState;
if (cropping) {
return { width: image.real_width, height: image.real_height };
Function cropReducer
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cropReducer(state: Crop.State, action: Crop.Action): Crop.State {
const {
crop_start_x,
crop_start_y,
crop_width,
Function EditableImage
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function EditableImage(props: Props) {
const [image, setImage] = useState(props.image);
const [src, setSrc] = useState(props.src);
const openModal = useModalStore((state) => state.open);
Function Metadata
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Metadata(props: Props) {
const { state, dispatch } = props;
const { page, locale, locales, inputDir, templateConfig } = state;
Function FocalPoint
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export default function FocalPoint(props: Props) {
const { width, height, onChange } = props;
const [dragging, setDragging] = useState(false);
const [position, setPosition] = useState<Crop.Position>({
- 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 ImageCropper
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ImageCropper(props: Props) {
const [containerRef, containerSize] = useContainerSize();
const setAspect = (aspect: number) => {
props.dispatch({ type: "setAspect", payload: aspect });
Function Toast
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Toast(props: Props) {
const [fadeout, setFadeout] = useState(false);
const { toasts, error, notice, next } = useToastStore((state) => state);
const timerRef = useRef<ReturnType<typeof setTimeout>>(null);
Function useDragUploader
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export default function useDragUploader<T>(
collections: Drag.Collection<T>[],
onDragEnd: (dragState: Drag.State<T>, files: File[]) => void
): [
Drag.State<T>,
- 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 GridImage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export default function GridImage(props: Props) {
const { attributeName, draggable } = props;
const record = draggable.record;
const image = record.image;
- 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 usePageTree
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function usePageTree(
pages: PageRecord[],
locale: string,
dir: string,
permissions: string[]
Function Modal
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function Modal() {
const component = useModalStore((state) => state.component);
const close = useModalStore((state) => state.close);
const handleClose = useCallback(
Function handleSubmit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = (evt: React.MouseEvent) => {
evt.preventDefault();
let method = postJson;
let url = `/admin/${locale}/pages.json`;
const data = {
Function PathSegment
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function PathSegment(props: Props) {
const { state, dispatch } = props;
const { page, locale } = state;
const value = (page.path_segment as LocalizedValue)[locale];