samvera/node-iiif

View on GitHub

Showing 4 of 4 total issues

File base.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const IIIFError = require('../error');
const debug = require('debug')('iiif-processor:calculator');

// Integer RegEx
const IR = '\\d+';
Severity: Minor
Found in src/calculator/base.js - About 2 hrs to fix

    Function createRouter has 46 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

    function createRouter(version) {
      const streamImageFromFile = ({ id }) => {
        const filename = fileTemplate.replace(/\{\{id\}\}/, id);
        const file = path.join(iiifImagePath, filename);
        if (!fs.existsSync(file)) {
    Severity: Minor
    Found in examples/tiny-iiif/iiif.js - About 1 hr to fix

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

      function createRouter(version) {
        const streamImageFromFile = ({ id }) => {
          const filename = fileTemplate.replace(/\{\{id\}\}/, id);
          const file = path.join(iiifImagePath, filename);
          if (!fs.existsSync(file)) {
      Severity: Minor
      Found in examples/tiny-iiif/iiif.js - 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 infoJson has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async infoJson () {
          const [dim] = await this.dimensions();
          const sizes = [];
          for (let size = [dim.width, dim.height]; size.every((x) => x >= 64); size = size.map((x) => Math.floor(x / 2))) {
            sizes.push({ width: size[0], height: size[1] });
      Severity: Minor
      Found in src/processor.js - 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

      Severity
      Category
      Status
      Source
      Language