anyone-oslo/pages

View on GitHub

Showing 77 of 115 total issues

Function containsFiles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function containsFiles(evt: Event) {
  if ("dataTransfer" in evt) {
    const dataTransfer: DataTransfer = evt.dataTransfer;
    if ("types" in dataTransfer) {
      const types = dataTransfer.types;
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 render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const props = this.props;
    const index = props.index;
    const dragging = props.dragging;
    const editing = this.node().editing;
Severity: Minor
Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

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

      render() {
        let { value, rows } = this.state;
        let { id, name } = this.props;
    
        const clickHandler = (fn) => (evt) => {
    Severity: Minor
    Found in app/javascript/components/RichTextArea.jsx - About 1 hr to fix

      Function childNodes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        childNodes() {
          const { index, tree, dragging, dir, locale } = this.props;
      
          if (index.children && index.children.length && !index.node.collapsed) {
            const childrenStyles = {};
      Severity: Minor
      Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

        Function AddTagForm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function AddTagForm(props: AddTagFormProps) {
          const [tag, setTag] = useState("");
        
          const submit = (evt: Event) => {
            evt.preventDefault();
        Severity: Minor
        Found in app/javascript/components/TagEditor/AddTagForm.tsx - About 1 hr to fix

          Function collapseArrow has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            collapseArrow() {
              const index = this.props.index;
          
              // Don't collapse the root node
              if (!index.parent) {
          Severity: Minor
          Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

            Function renderNode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              renderNode() {
                const index = this.props.index;
                const node = index.node;
            
                let pageName = <span className="name">{this.pageName()}</span>;
            Severity: Minor
            Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

              Function useCrop has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function useCrop(image: ImageResource) {
                const initialState: CropState = {
                  aspect: null,
                  cropping: false,
                  crop_start_x: image.crop_start_x || 0,
              Severity: Minor
              Found in app/javascript/components/ImageCropper/useCrop.ts - About 1 hr to fix

                Function dragCollectionReducer has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function dragCollectionReducer(
                  state: Draggable[],
                  action: DragCollectionAction
                ): Draggable[] {
                  switch (action.type) {
                Severity: Minor
                Found in app/javascript/components/drag/useDragCollection.ts - About 1 hr to fix

                  Function getFiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getFiles(dt: DataTransfer): File[] {
                    const files: File[] = [];
                    if (dt.items) {
                      for (let i = 0; i < dt.items.length; i++) {
                        if (dt.items[i].kind == "file") {
                  Severity: Minor
                  Found in app/javascript/components/drag/useDragUploader.ts - About 55 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 cropReducer has a Cognitive Complexity of 9 (exceeds 5 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 55 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 AttachmentEditor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function AttachmentEditor(props: AttachmentEditorProps) {
                    const { attachment, locales } = props;
                  
                    const [locale, setLocale] = useState(props.locale);
                    const [localizations, setLocalizations] = useState({
                  Severity: Minor
                  Found in app/javascript/components/Attachments/AttachmentEditor.tsx - About 55 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

                  Method meta_description has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def meta_description(*args)
                        if args.any?
                          @meta_description = args.first
                        else
                          description = @meta_description
                  Severity: Minor
                  Found in app/helpers/pages_core/meta_tags_helper.rb - About 55 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 getFiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getFiles(dt: DataTransfer): File[] {
                    const files: File[] = [];
                    if (dt.items) {
                      for (let i = 0; i < dt.items.length; i++) {
                        if (dt.items[i].kind == "file") {
                  Severity: Minor
                  Found in app/javascript/components/ImageUploader.tsx - About 55 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 Attachments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function Attachments(props) {
                    const collection = useDragCollection(props.records);
                    const locales =
                      props.locales && props.locales.length > 0
                        ? Object.keys(props.locales)
                  Severity: Minor
                  Found in app/javascript/components/Attachments.jsx - About 55 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 applyCollapsed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    applyCollapsed(tree: Tree<PageNode>) {
                      const depth = (t: Tree, index: TreeIndex) => {
                        let depth = 0;
                        let pointer = t.getIndex(index.parent);
                        while (pointer) {
                  Severity: Minor
                  Found in app/javascript/components/PageTree.tsx - About 55 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

                  Consider simplifying this complex logical expression.
                  Open

                    if (draggable === "Files") {
                      return "";
                    } else {
                      const containerSize = container.current.getBoundingClientRect();
                      const x = dragState.x - (containerSize.x || containerSize.left);
                  Severity: Major
                  Found in app/javascript/components/ImageGrid/DragElement.tsx - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                          if ("touches" in evt && evt.type == "touchmove") {
                            x = evt.touches[0].clientX - (containerSize.x || containerSize.left);
                            y = evt.touches[0].clientY - (containerSize.y || containerSize.top);
                          } else {
                            x = evt.clientX - (containerSize.x || containerSize.left);
                    Severity: Major
                    Found in app/javascript/components/ImageCropper/FocalPoint.tsx - About 40 mins to fix

                      Method labelled_check_box has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                            attr, label = nil, options = {}, checked = "1", unchecked = "0"
                      Severity: Minor
                      Found in app/helpers/pages_core/labelled_form_builder.rb - About 35 mins to fix

                        Function Form has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export default function Form(props: FormProps) {
                          const { alternative, caption, image, locale, locales } = props;
                        
                          const closeModal = useModalStore((state) => state.close);
                          const notice = useToastStore((state) => state.notice);
                        Severity: Minor
                        Found in app/javascript/components/ImageEditor/Form.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