Showing 21 of 27 total issues
File Acetate.js
has 636 lines of code (exceeds 250 allowed). Consider refactoring. Open
const EventEmitter = require("events").EventEmitter;
const chokidar = require("chokidar");
const path = require("path");
const fs = require("fs");
const _ = require("lodash");
Function createServer
has 158 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createServer(acetate, options = {}) {
function notFoundMiddleware(request, response) {
acetate.log.warn(`404 not found ${url.parse(request.url).pathname}`);
response.writeHead(404, { "Content-Type": "text/html" });
response.end(notFoundPageTemplate);
Acetate
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class Acetate extends EventEmitter {
constructor({
config = "acetate.config.js",
sourceDir = "src",
outDir = "build",
Function reloadConfig
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
reloadConfig() {
this.emit("config:reloading");
this.reset();
this.require("./helpers/highlight-block.js");
Function exports
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(acetate) {
acetate.helper(
"link",
function(context, destinationUrl, text) {
const currentUrl = context.options.currentUrl || context.page.url;
- Read upRead up
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 exports
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(acetate) {
acetate.helper(
"link",
function(context, destinationUrl, text) {
const currentUrl = context.options.currentUrl || context.page.url;
Function exports
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(acetate) {
const pagesCache = {};
const acetateMiddleware = function acetateMiddleware(
request,
Function acetateMiddleware
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
const acetateMiddleware = function acetateMiddleware(
request,
response,
next
) {
Function createServer
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function createServer(acetate, options = {}) {
function notFoundMiddleware(request, response) {
acetate.log.warn(`404 not found ${url.parse(request.url).pathname}`);
response.writeHead(404, { "Content-Type": "text/html" });
response.end(notFoundPageTemplate);
- Read upRead up
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 createWatcher
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function createWatcher(acetate) {
function removePage(page) {
const outputPath = path.join(acetate.outDir, page.dest);
deleteFile(outputPath)
.then(function() {
Function _createLoaderTask
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createLoaderTask(
pattern,
{ ignore = [], metadata = {}, basePath = "" } = {}
) {
return (createPage, callback) => {
Function reset
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
reset() {
this._paths = [];
this._pages = [];
this._pagesLoaded = false;
this._loaders = [];
Function _handlePageWatcherEvent
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handlePageWatcherEvent(src, eventName, verb) {
this.log.info(`${src} ${verb}`);
if (path.basename(src)[0] === "_") {
this.emit(`watcher:template:${eventName}`, src);
} else {
Function run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function run() {
if (argv.require && argv.require.length) {
argv.require.forEach(dep => {
require(dep);
});
Function transform
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
transform(pattern, transformer, label) {
const matcher = new minimatch.Minimatch(pattern);
const transformRunner = function(page, done) {
if (!matcher.match(page.src)) {
process.nextTick(() => {
- Read upRead up
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 startPageWatcher
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
startPageWatcher() {
if (this._pageWatcher) {
this.stopWatcher();
}
Function constructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(error, page) {
error = typeof error === "string" ? new Error(error) : error;
let originalMessage = _.trim(_.last(error.message.split("\n")));
if (/ \[(Line) \d+, Column \d+\]/.test(error.message)) {
let originalErrorLocation = error.message.match(/.*: \((.*)\)/);
Function transform
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
transform(pattern, transformer, label) {
const matcher = new minimatch.Minimatch(pattern);
const transformRunner = function(page, done) {
if (!matcher.match(page.src)) {
process.nextTick(() => {
Function done
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const done = (error, filepaths) => {
if (error) {
callback(error);
}
Function fromTemplate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fromTemplate(src, templatePath, defaultMetadata = {}, options) {
const filename = path.basename(templatePath, path.extname(templatePath));
const dirname = path.dirname(templatePath);
const yamlMetadataPath = path.join(dirname, `${filename}.metadata.yaml`);
const jsonMetadataPath = path.join(dirname, `${filename}.metadata.json`);