anyone-oslo/pages

View on GitHub

Showing 77 of 115 total issues

Function render has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    return (
      <div className="date-range-select">
        <input
          type="hidden"
Severity: Minor
Found in app/javascript/components/DateRangeSelect.jsx - About 1 hr to fix

    Function cropReducer has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function cropReducer(state: CropState, action: CropAction): CropState {
      const {
        crop_start_x,
        crop_start_y,
        crop_width,
    Severity: Minor
    Found in app/javascript/components/ImageCropper/useCrop.ts - About 1 hr to fix

      Function ImageEditor has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function ImageEditor(props: ImageEditorProps) {
        const [cropState, dispatch, croppedImage] = useCrop(props.image);
        const [locale, setLocale] = useState(props.locale);
        const [localizations, setLocalizations] = useState({
          caption: props.image.caption || {},
      Severity: Minor
      Found in app/javascript/components/ImageEditor.tsx - About 1 hr to fix

        Function actions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          actions() {
            const statusLabel = this.node().status != 2 ? "Publish" : "Hide";
            const statusIcon = this.node().status != 2 ? "check" : "ban";
        
            if (this.node().editing) {
        Severity: Minor
        Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

          Function Image has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function Image(props: ImageProps) {
            const imageSize = () => {
              const { image, cropping, crop_width, crop_height } = props.cropState;
              if (cropping) {
                return { width: image.real_width, height: image.real_height };
          Severity: Minor
          Found in app/javascript/components/ImageCropper/Image.tsx - About 1 hr to fix

            Function render has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                const addChild = (id: TreeId, attributes: Attributes) => {
                  const tree = this.state.tree;
                  const index = tree.append(attributes, id);
                  this.reorderChildren(id);
            Severity: Minor
            Found in app/javascript/components/PageTree.tsx - About 1 hr to fix

              Function EditableImage has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function EditableImage(props: EditableImageProps) {
                const [image, setImage] = useState(props.image);
                const [src, setSrc] = useState(props.src);
              
                const openModal = useModalStore((state) => state.open);
              Severity: Minor
              Found in app/javascript/components/EditableImage.tsx - About 1 hr to fix

                Function FocalPoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function FocalPoint(props: FocalPointProps) {
                  const { width, height, onChange } = props;
                
                  const [dragging, setDragging] = useState(false);
                  const [position, setPosition] = useState<Position>({
                Severity: Minor
                Found in app/javascript/components/ImageCropper/FocalPoint.tsx - About 1 hr 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 TagEditor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function TagEditor(props: TagEditorProps) {
                  const [tags, setTags] = useState(props.tags);
                  const [enabled, setEnabled] = useState(props.enabled);
                
                  const tagList = [...tags, ...enabled].filter(onlyUnique);
                Severity: Minor
                Found in app/javascript/components/TagEditor.tsx - About 1 hr to fix

                  Function updateNodesPosition has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    updateNodesPosition() {
                      let top = 1;
                      let left = 1;
                      const root = this.getIndex(1);
                  
                  
                  Severity: Minor
                  Found in app/javascript/lib/Tree.ts - About 1 hr to fix

                    Function Toast has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function Toast(props: ToastProps) {
                      const [fadeout, setFadeout] = useState(false);
                      const { toasts, error, notice, next } = useToastStore((state) => state);
                      const timerRef = useRef<number | null>(null);
                    
                    
                    Severity: Minor
                    Found in app/javascript/components/Toast.tsx - About 1 hr to fix

                      Function useDragUploader has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export default function useDragUploader(
                        collections: DragCollection[],
                        onDragEnd: (dragState: DragState, files: File[]) => void
                      ) {
                        const initialState: DragState = {
                      Severity: Minor
                      Found in app/javascript/components/drag/useDragUploader.ts - About 1 hr 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 renderEditNode has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        renderEditNode() {
                          const { dir, locale } = this.props;
                      
                          const handleNameChange = (event: ChangeEvent<HTMLInputElement>) => {
                            this.setState({ newName: event.target.value });
                      Severity: Minor
                      Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

                        Function build has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          build(obj: N): TreeIndex<N> {
                            const indexes = this.indexes;
                            const startId = this.cnt;
                        
                            const index = { id: startId, node: obj };
                        Severity: Minor
                        Found in app/javascript/lib/Tree.ts - About 1 hr to fix

                          Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              return (
                                <div className="page-dates field">
                                  <input
                                    type="hidden"
                          Severity: Minor
                          Found in app/javascript/components/PageDates.jsx - About 1 hr to fix

                            Function GridImage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export default function GridImage(props: GridImageProps) {
                              const { attributeName, draggable } = props;
                              const record = draggable.record;
                              const image = record.image;
                            
                            
                            Severity: Minor
                            Found in app/javascript/components/ImageGrid/GridImage.tsx - About 1 hr 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 Modal has 35 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 = (evt: Event) => {
                            Severity: Minor
                            Found in app/javascript/components/Modal.tsx - About 1 hr to fix

                              Function uploadImage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                const uploadImage = (file: File) => {
                                  const validTypes = [
                                    "image/gif",
                                    "image/jpeg",
                                    "image/pjpeg",
                              Severity: Minor
                              Found in app/javascript/components/ImageUploader.tsx - About 1 hr to fix

                                Function renderDateSelect has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  renderDateSelect(key, date, handleChange) {
                                    return (
                                      <div className="date-select">
                                        <select
                                          value={date.getMonth()}
                                Severity: Minor
                                Found in app/javascript/components/DateRangeSelect.jsx - About 1 hr to fix

                                  Function FileUploadButton has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export default function FileUploadButton(props: FileUploadButtonProps) {
                                    const inputRef = useRef<HTMLInputElement>();
                                  
                                    const handleChange = (evt: ChangeEvent<HTMLInputElement>) => {
                                      const fileList = evt.target.files;
                                  Severity: Minor
                                  Found in app/javascript/components/FileUploadButton.tsx - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language