makeomatic/ms-files

View on GitHub
src/actions/update.js

Summary

Maintainability
C
1 day
Test Coverage

Function updateMeta has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

async function updateMeta(lock, ctx, params) {
  const { uploadId, username, directOnly, immutable, includeReferences } = params;
  const { redis } = ctx;
  const key = FILES_DATA_INDEX_KEY(uploadId);
  const meta = preProcessMetadata(params.meta);
Severity: Minor
Found in src/actions/update.js - About 7 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

Function updateMeta has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function updateMeta(lock, ctx, params) {
  const { uploadId, username, directOnly, immutable, includeReferences } = params;
  const { redis } = ctx;
  const key = FILES_DATA_INDEX_KEY(uploadId);
  const meta = preProcessMetadata(params.meta);
Severity: Major
Found in src/actions/update.js - About 4 hrs to fix

    Function preProcessMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function preProcessMetadata(data) {
      const { description, alias } = data;
    
      // Trim extra spaces in case of typo
      if (description != null && typeof description === 'string') {
    Severity: Minor
    Found in src/actions/update.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

    Parsing error: The keyword 'const' is reserved
    Open

    const { ActionTransport } = require('@microfleet/plugin-router');
    Severity: Minor
    Found in src/actions/update.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status