anyone-oslo/pages

View on GitHub

Showing 117 of 117 total issues

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

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

            if (crop.crop_start_y + crop.crop_height > state.image.real_height) {
              crop.crop_height = state.image.real_height - crop.crop_start_y;
            }
          Severity: Major
          Found in app/javascript/components/ImageCropper/useCrop.ts and 1 other location - About 1 hr to fix
          app/javascript/components/ImageCropper/useCrop.ts on lines 156..158

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

          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 (crop.crop_start_x + crop.crop_width > state.image.real_width) {
              crop.crop_width = state.image.real_width - crop.crop_start_x;
            }
          Severity: Major
          Found in app/javascript/components/ImageCropper/useCrop.ts and 1 other location - About 1 hr to fix
          app/javascript/components/ImageCropper/useCrop.ts on lines 160..162

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

          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

          DateRangeSelect.propTypes = {
            startsAt: PropTypes.string,
            endsAt: PropTypes.string,
            disabled: PropTypes.bool,
            disableTime: PropTypes.bool,
          Severity: Major
          Found in app/javascript/components/DateRangeSelect.jsx and 1 other location - About 1 hr to fix
          app/javascript/components/Attachments.jsx on lines 172..178

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

          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

          Attachments.propTypes = {
            attribute: PropTypes.string,
            locale: PropTypes.string,
            locales: PropTypes.object,
            records: PropTypes.array,
          Severity: Major
          Found in app/javascript/components/Attachments.jsx and 1 other location - About 1 hr to fix
          app/javascript/components/DateRangeSelect.jsx on lines 219..225

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

          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 4 locations. Consider refactoring.
          Open

            const copyEmbedCode = (evt: MouseEvent) => {
              evt.preventDefault();
              copyToClipboard(`[image:${image.id}]`);
              notice("Embed code copied to clipboard");
            };
          Severity: Major
          Found in app/javascript/components/ImageEditor/Form.tsx and 3 other locations - About 1 hr to fix
          app/javascript/components/Attachments/Attachment.tsx on lines 41..45
          app/javascript/components/Attachments/AttachmentEditor.tsx on lines 35..39
          app/javascript/components/ImageGrid/GridImage.tsx on lines 50..54

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

          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 4 locations. Consider refactoring.
          Open

            const copyEmbed = (evt: MouseEvent) => {
              evt.preventDefault();
              copyToClipboard(`[image:${image.id}]`);
              notice("Embed code copied to clipboard");
            };
          Severity: Major
          Found in app/javascript/components/ImageGrid/GridImage.tsx and 3 other locations - About 1 hr to fix
          app/javascript/components/Attachments/Attachment.tsx on lines 41..45
          app/javascript/components/Attachments/AttachmentEditor.tsx on lines 35..39
          app/javascript/components/ImageEditor/Form.tsx on lines 24..28

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

          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 4 locations. Consider refactoring.
          Open

            const copyEmbed = (evt: MouseEvent) => {
              evt.preventDefault();
              copyToClipboard(`[attachment:${attachment.id}]`);
              notice("Embed code copied to clipboard");
            };
          Severity: Major
          Found in app/javascript/components/Attachments/Attachment.tsx and 3 other locations - About 1 hr to fix
          app/javascript/components/Attachments/AttachmentEditor.tsx on lines 35..39
          app/javascript/components/ImageEditor/Form.tsx on lines 24..28
          app/javascript/components/ImageGrid/GridImage.tsx on lines 50..54

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

          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 4 locations. Consider refactoring.
          Open

            const copyEmbedCode = (evt: MouseEvent) => {
              evt.preventDefault();
              copyToClipboard(`[attachment:${attachment.id}]`);
              notice("Embed code copied to clipboard");
            };
          Severity: Major
          Found in app/javascript/components/Attachments/AttachmentEditor.tsx and 3 other locations - About 1 hr to fix
          app/javascript/components/Attachments/Attachment.tsx on lines 41..45
          app/javascript/components/ImageEditor/Form.tsx on lines 24..28
          app/javascript/components/ImageGrid/GridImage.tsx on lines 50..54

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

          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 walk has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const walk = (objs: Tree.Node[], parent: Tree.Index<N>) => {
                const children: Tree.Id[] = [];
                objs.forEach((obj: N) => {
                  const index: Tree.Index<N> = {
                    id: this.cnt,
          Severity: Minor
          Found in app/javascript/lib/Tree.ts - About 1 hr to fix

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

            export default function useCrop(
              image: ImageResource
            ): [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 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 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

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

              Severity
              Category
              Status
              Source
              Language