anyone-oslo/pages

View on GitHub

Showing 71 of 137 total issues

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 });
Severity: Minor
Found in app/javascript/components/TagEditor/AddTagForm.tsx - About 1 hr to fix

    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",
    Severity: Minor
    Found in app/javascript/components/ImageUploader.tsx - About 1 hr to fix

      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) => {
      Severity: Minor
      Found in app/javascript/components/PageTree/usePageTree.ts - About 1 hr to fix

        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;
        Severity: Minor
        Found in app/javascript/components/FileUploadButton.tsx - About 1 hr to fix

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

          export function updatePage(
            state: State,
            id: Tree.Id,
            dispatch: (action: Action) => void,
            attributes: Partial<PageRecord>
          Severity: Minor
          Found in app/javascript/components/PageTree/usePageTree.ts - About 1 hr to fix

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

            export default function Content(props: Props) {
              const { state, dispatch, tagsState, tagsDispatch } = props;
            
              const { page, locale, inputDir, templateConfig } = state;
            
            
            Severity: Minor
            Found in app/javascript/components/PageForm/Content.tsx - About 1 hr to fix

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

              function pageImages(state: Images.GridState) {
                const primary = state.primary.draggables
                  .filter((r) => r !== "Files")
                  .map((r: Drag.Draggable<Images.Record>, i: number) => {
                    const pi = r.record;
              Severity: Minor
              Found in app/javascript/components/PageForm/pageParams.ts - About 1 hr to fix

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

                export default function useCrop(
                  image: Images.Resource
                ): [Crop.State, (action: Crop.Action) => void, string] {
                  const initialState: Crop.State = {
                    aspect: null,
                Severity: Minor
                Found in app/javascript/components/ImageCropper/useCrop.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: Crop.State, action: Crop.Action): Crop.State {
                    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: Props) {
                    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 usePageTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function usePageTree(
                    pages: PageRecord[],
                    locale: string,
                    dir: string,
                    permissions: string[]
                  Severity: Minor
                  Found in app/javascript/components/PageTree/usePageTree.ts - About 45 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 List has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function List(props: Props) {
                    const { collection, deleted, setDeleted } = props.state;
                    const locales = props.locales ? Object.keys(props.locales) : [props.locale];
                  
                    const uploadAttachment = (file: File) => {
                  Severity: Minor
                  Found in app/javascript/components/Attachments/List.tsx - About 45 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 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 containsFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function containsFiles(evt: AnyTouchEvent) {
                      if ("dataTransfer" in evt) {
                        const dataTransfer = evt.dataTransfer as DataTransfer;
                        const types = dataTransfer.types;
                        for (let i = 0; i < types.length; i++) {
                    Severity: Minor
                    Found in app/javascript/components/drag/useDragUploader.ts - 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

                    Function Image has a Cognitive Complexity of 7 (exceeds 5 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 };
                    Severity: Minor
                    Found in app/javascript/components/ImageCropper/Image.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

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

                    export default function Form(props: Props) {
                      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

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

                    export default function FileUploadButton(props: Props) {
                      const inputRef = useRef<HTMLInputElement>();
                    
                      const handleChange = (evt: ChangeEvent<HTMLInputElement>) => {
                        const fileList = evt.target.files;
                    Severity: Minor
                    Found in app/javascript/components/FileUploadButton.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