anyone-oslo/pages

View on GitHub

Showing 77 of 117 total issues

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 collapseArrow has a Cognitive Complexity of 7 (exceeds 5 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 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 connect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  connect() {
    const tabs = this.tabNames();
    if (tabs.length > 0) {
      let initTab: string = null;
      const tabExpression = /#(.*)$/;
Severity: Minor
Found in app/javascript/controllers/MainController.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 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

Method redirect_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def redirect_path(params = {})
        path = redirect_to.dup
        if path.start_with? "/"
          params.each do |key, value|
            unless value.is_a?(String) || value.is_a?(Symbol)
Severity: Minor
Found in app/models/concerns/pages_core/page_model/redirectable.rb - About 25 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 DragElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function DragElement(props: Props) {
  const { draggable, dragState, container } = props;

  if (draggable === "Files") {
    return "";
Severity: Minor
Found in app/javascript/components/ImageGrid/DragElement.tsx - About 25 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 move has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  move(fromId: Tree.Id, toId: Tree.Id, placement: MovePlacement) {
    if (fromId === toId || toId === 1) {
      return;
    }

Severity: Minor
Found in app/javascript/lib/Tree.ts - About 25 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 hovering has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function hovering(
  dragState: Drag.State,
  target: Drag.Item | React.MutableRefObject<HTMLDivElement>
) {
  const { x, y } = dragState;
Severity: Minor
Found in app/javascript/components/drag/draggedOrder.ts - About 25 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 handleKeyPress has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  handleKeyPress(evt) {
    let key;
    if (evt.which >= 65 && evt.which <= 90) {
      key = String.fromCharCode(evt.keyCode).toLowerCase();
    } else if (evt.keyCode === 13) {
Severity: Minor
Found in app/javascript/components/RichTextArea.jsx - About 25 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 ImageCropper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function ImageCropper(props: Props) {
  const containerRef = useRef<HTMLDivElement>();
  const [containerSize, setContainerSize] = useState<Crop.Size>();

  const handleResize = () => {
Severity: Minor
Found in app/javascript/components/ImageCropper.tsx - About 25 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 relativeUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  relativeUrl(str) {
    let url = null;

    if (!str.match(/^https:\/\//) || !document || !document.location) {
      return str;
Severity: Minor
Found in app/javascript/components/RichTextArea.jsx - About 25 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 setting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.setting(key, type, default = nil)
        settings[key] = SettingStruct.new(type, default)

        define_method key do |*args|
          args.any? ? set(key, *args) : get(key)
Severity: Minor
Found in lib/pages_core/configuration/base.rb - About 25 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 actions has a Cognitive Complexity of 6 (exceeds 5 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 25 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 modifyDate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  modifyDate(original, options = {}) {
    var newDate = new Date(original);
    if (Object.prototype.hasOwnProperty.call(options, "year")) {
      newDate.setFullYear(options.year);
    }
Severity: Minor
Found in app/javascript/components/DateRangeSelect.jsx - About 25 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 collectionOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function collectionOrder(
  collection: Drag.Collection,
  dragState: Drag.State
) {
  const { draggables, ref } = collection;
Severity: Minor
Found in app/javascript/components/drag/draggedOrder.ts - About 25 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 getNodeByTop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  getNodeByTop(top: Tree.Id) {
    const indexes = this.indexes;
    for (const id in indexes) {
      if (Object.prototype.hasOwnProperty.call(indexes, id)) {
        if (indexes[id].top === top) {
Severity: Minor
Found in app/javascript/lib/Tree.ts - About 25 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 Modal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function Modal() {
  const component = useModalStore((state) => state.component);
  const close = useModalStore((state) => state.close);

  const handleClose = (evt: KeyboardEvent | MouseEvent) => {
Severity: Minor
Found in app/javascript/components/Modal.tsx - About 25 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