dopry/netlify-cms

View on GitHub
src/backends/backend.js

Summary

Maintainability
B
5 hrs
Test Coverage

File backend.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { attempt, isError } from 'lodash';
import TestRepoBackend from "./test-repo/implementation";
import GitHubBackend from "./github/implementation";
import GitGatewayBackend from "./git-gateway/implementation";
import { resolveFormat } from "../formats/formats";
Severity: Minor
Found in src/backends/backend.js - About 2 hrs to fix

    Function persistEntry has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      persistEntry(config, collection, entryDraft, MediaFiles, options) {
        const newEntry = entryDraft.getIn(["entry", "newRecord"]) || false;
    
        const parsedData = {
          title: entryDraft.getIn(["entry", "data", "title"], "No Title"),
    Severity: Minor
    Found in src/backends/backend.js - About 1 hr to fix

      Function slugFormatter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const slugFormatter = (template = "{{slug}}", entryData) => {
        const date = new Date();
      
        const getIdentifier = (entryData) => {
          const validIdentifierFields = ["title", "path"];
      Severity: Minor
      Found in src/backends/backend.js - About 1 hr to fix

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

          persistEntry(config, collection, entryDraft, MediaFiles, options) {
            const newEntry = entryDraft.getIn(["entry", "newRecord"]) || false;
        
            const parsedData = {
              title: entryDraft.getIn(["entry", "data", "title"], "No Title"),
        Severity: Minor
        Found in src/backends/backend.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