Ch4s3/ink_stream

View on GitHub
app/javascript/ink-stream/turboPatch.js

Summary

Maintainability
A
2 hrs
Test Coverage

Function preload has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

const preload = function(event) {
  let link = Turbolinks.controller.getVisitableLinkForNode(event.target);
  if (link) {
    let location = Turbolinks.controller.getVisitableLocationForLink(link);
    if (location) {
Severity: Minor
Found in app/javascript/ink-stream/turboPatch.js - About 2 hrs 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

Avoid too many return statements within this function.
Invalid

    return false;
Severity: Major
Found in app/javascript/ink-stream/turboPatch.js - About 30 mins to fix

    Function notPreloadable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Invalid

    const notPreloadable = function(link, location){
      if (preloadAttribute(link) === false) {
        return true;
      } else if (isNotGetMethod(link)) {
        return true;
    Severity: Minor
    Found in app/javascript/ink-stream/turboPatch.js - 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

    There are no issues that match your filters.

    Category
    Status