anyone-oslo/pages

View on GitHub

Showing 71 of 137 total issues

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

export default function Block(props: Props) {
  const { block, errors, onChange, lang, dir, value } = props;

  const handleChange = (
    evt: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
Severity: Minor
Found in app/javascript/components/PageForm/Block.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 DateRangeSelect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function DateRangeSelect(props: Props) {
  const { disabled, disableTime, objectName } = props;

  const [uncontrolledStartsAt, setUncontrolledStartsAt] = useState(
    parseDate(props.startsAt)
Severity: Minor
Found in app/javascript/components/DateRangeSelect.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 collectionOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function collectionOrder<T>(
  collection: Drag.Collection<T>,
  dragState: Drag.State<T>
): Array<Drag.Item<T>> {
  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 relativeUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function relativeUrl(str: string): string {
  let url: URL = null;

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

export function unconfiguredBlocks(state: PageEditor.State): Template.Block[] {
  const allBlocks: Record<string, Template.Block> = state.templates
    .flatMap((t) => t.blocks)
    .reduce((bs, b) => ({ [b.name]: b, ...bs }), {});

Severity: Minor
Found in app/javascript/components/PageForm/usePage.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 modifyDate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function modifyDate(original: Date, options: ModifyOptions = {}): Date {
  const newDate = new Date(original);
  if ("year" in options) {
    newDate.setFullYear(options.year);
  }
Severity: Minor
Found in app/javascript/components/DateTimeSelect.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

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

    def reify_options(block)
      return block unless block.key?(:options)

      opts = block[:options]
      opts = opts.call if opts.is_a?(Proc)
Severity: Minor
Found in app/resources/admin/template_configuration_resource.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 hovering has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function hovering<T>(
  dragState: Drag.State<T>,
  target: Drag.Item<T> | 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

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

Severity
Category
Status
Source
Language