anyone-oslo/pages

View on GitHub

Showing 130 of 130 total issues

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

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            {endsAt && (
              <div className="date">
                <DateTimeSelect
                  name={objectName + "[ends_at]"}
                  disabled={disabled}
      Severity: Major
      Found in app/javascript/components/DateRangeSelect.tsx and 1 other location - About 1 hr to fix
      app/javascript/components/DateRangeSelect.tsx on lines 83..93

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 70.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      export default function RichTextArea({
        id,
        name,
        value: initialValue,
        rows,
      Severity: Minor
      Found in app/javascript/components/RichTextArea.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            {startsAt && (
              <div className="date">
                <DateTimeSelect
                  name={objectName + "[starts_at]"}
                  disabled={disabled}
      Severity: Major
      Found in app/javascript/components/DateRangeSelect.tsx and 1 other location - About 1 hr to fix
      app/javascript/components/DateRangeSelect.tsx on lines 95..105

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 70.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

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

        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;
        
        
        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 usePageTree has 39 lines of code (exceeds 25 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 1 hr to fix

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

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

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

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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      if (templates.filter((t) => t.images).length > 0) {
                        tabs.push({ id: "images", name: "Images", enabled: templateConfig.images });
                      }
                    Severity: Major
                    Found in app/javascript/components/PageForm/useTabs.ts and 1 other location - About 1 hr to fix
                    app/javascript/components/PageForm/useTabs.ts on lines 14..16

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 62.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      if (templates.filter((t) => t.files).length > 0) {
                        tabs.push({ id: "files", name: "Files", enabled: templateConfig.files });
                      }
                    Severity: Major
                    Found in app/javascript/components/PageForm/useTabs.ts and 1 other location - About 1 hr to fix
                    app/javascript/components/PageForm/useTabs.ts on lines 11..13

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 62.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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 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 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

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                                      <label className="check-box">
                                        <input
                                          name="page[news_page]"
                                          type="checkbox"
                                          onChange={handleChecked("news_page")}
                          Severity: Major
                          Found in app/javascript/components/PageForm/Options.tsx and 2 other locations - About 1 hr to fix
                          app/javascript/components/PageForm/Options.tsx on lines 96..104
                          app/javascript/components/PageForm/Options.tsx on lines 130..138

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 60.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language