codevise/pageflow

View on GitHub
entry_types/scrolled/package/src/editor/models/ScrolledEntry/moveContentElement.js

Summary

Maintainability
A
2 hrs
Test Coverage

Function moveContentElement has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

export function moveContentElement(entry, contentElement, {range, sibling, at, splitPoint}) {
  const sourceBatch = new Batch(entry, contentElement.section);

  // If we move content elements between sections, merges will need to
  // be performed in the section where the content element came from.

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

Consider simplifying this complex logical expression.
Open

  if (!(at === 'before' && !range && sibling === after) &&
      !(at === 'after' && !range && sibling === before)) {
    sourceBatch.remove(contentElement);

    if (at === 'before') {

    There are no issues that match your filters.

    Category
    Status