Showing 65 of 130 total issues
Function Node
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export default function Node(props: Props) {
const { state, dispatch } = usePageTreeContext();
const { id, dragging, onDragStart } = props;
const { dir, locale } = state;
const node = state.nodes[id];
- 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() {
const { state, dispatch } = usePageFormContext();
const { datesEnabled, page } = state;
const toggleAllDay = () => {
Function reducer
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reducer(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() {
const { state, dispatch } = usePageFormContext();
const { page, locale, locales, inputDir, templateConfig } = state;
Function RichTextArea
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export default function RichTextArea({
id,
name,
value: initialValue,
rows,
- 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 FocalPoint
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export default function FocalPoint(props: Props) {
const { width, height } = props;
const { state, dispatch } = useImageCropperContext();
const [dragging, setDragging] = useState(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 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 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 PathSegment
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function PathSegment() {
const { state, dispatch } = usePageFormContext();
const { page, locale } = state;
const value = (page.path_segment as LocalizedValue)[locale];
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 AddTagForm
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function AddTagForm(props: Props) {
const [tag, setTag] = useState("");
const submit = () => {
props.dispatch({ type: "addTag", payload: tag });
Function ImageEditor
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function ImageEditor(props: Props) {
const [cropState, cropDispatch, croppedImage] = useCrop(props.image);
const [state, dispatch, options] = useImageEditor(props);
Function uploadImage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const uploadImage = (file: File) => {
const validTypes = [
"image/gif",
"image/jpeg",
"image/pjpeg",
Function FileUploadButton
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function FileUploadButton(props: Props) {
const inputRef = useRef<HTMLInputElement>();
const handleChange = (evt: ChangeEvent<HTMLInputElement>) => {
const fileList = evt.target.files;
Function reducer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reducer(state: State, action: Action): State {
const { id, type } = action;
const chain = (operations: Array<Partial<Action>>) => {
return operations.reduce((s, o) => {
Function updatePage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updatePage(
state: State,
id: Tree.Id,
dispatch: React.Dispatch<Action>,
attributes: Partial<PageRecord>