Showing 103 of 172 total issues
Function escapeAllSwigTags
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
escapeAllSwigTags(str: string) {
if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/s.test(str)) {
return str;
}
let state = STATE_PLAINTEXT;
- 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
File index.ts
has 500 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Promise from 'bluebird';
import { sep, join, dirname } from 'path';
import tildify from 'tildify';
import Database from 'warehouse';
import { magenta, underline } from 'picocolors';
Function openGraphHelper
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
function openGraphHelper(this: LocalsType, options: Options = {}) {
const { config, page } = this;
const { content } = page;
let images = options.image || options.images || page.photos || [];
let description = options.description || page.description || page.excerpt || content || config.description;
- 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 parseArgs
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
function parseArgs(args: string[]): HighlightOptions {
const _else = [];
const len = args.length;
let lang: string, language_attr: boolean,
line_number: boolean, line_threshold: number, wrap: boolean;
- 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 listArchivesHelper
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
function listArchivesHelper(this: LocalsType, options: Options = {}) {
const { config } = this;
const archiveDir = config.archive_dir;
const { timezone } = config;
const lang = toMomentLocale(this.page.lang || this.page.language || config.language);
- 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
File post.ts
has 372 lines of code (exceeds 250 allowed). Consider refactoring. Open
import assert from 'assert';
import moment from 'moment';
import Promise from 'bluebird';
import { join, extname, basename } from 'path';
import { magenta } from 'picocolors';
Function tocHelper
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function tocHelper(str: string, options: Options = {}) {
options = Object.assign({
min_depth: 1,
max_depth: 6,
class: 'toc',
- 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 escapeAllSwigTags
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
escapeAllSwigTags(str: string) {
if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/s.test(str)) {
return str;
}
let state = STATE_PLAINTEXT;
Function openGraphHelper
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
function openGraphHelper(this: LocalsType, options: Options = {}) {
const { config, page } = this;
const { content } = page;
let images = options.image || options.images || page.photos || [];
let description = options.description || page.description || page.excerpt || content || config.description;
Function processPost
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processPost(ctx: Hexo, file: _File) {
const Post = ctx.model('Post');
const { path } = file.params;
const doc = Post.findOne({source: file.path});
const { config } = ctx;
Function postPermalinkFilter
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function postPermalinkFilter(this: Hexo, data: PostSchema): string {
const { config } = this;
const { id, _id, slug, title, date } = data;
let { __permalink } = data;
const { post_asset_folder } = config;
- 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 parseArgs
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseArgs(args: string[]): HighlightOptions {
const _else = [];
const len = args.length;
let lang: string, language_attr: boolean,
line_number: boolean, line_threshold: number, wrap: boolean;
Function makeFeedTag
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function makeFeedTag(this: LocalsType, path?: string, options: Options = {}, configFeed?: any, configTitle?: string) {
const title = options.title || configTitle;
if (path) {
if (typeof path !== 'string') throw new TypeError('path must be a string!');
- 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 listCategoriesHelper
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
function listCategoriesHelper(this: LocalsType, categories?: Query<CategorySchema> | Options, options?: Options) {
if (!options && (!categories || !Object.prototype.hasOwnProperty.call(categories, 'length'))) {
options = categories as Options;
categories = this.site.categories;
}
Function listArchivesHelper
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
function listArchivesHelper(this: LocalsType, options: Options = {}) {
const { config } = this;
const archiveDir = config.archive_dir;
const { timezone } = config;
const lang = toMomentLocale(this.page.lang || this.page.language || config.language);
Function numberFormatHelper
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function numberFormatHelper(num: number, options: Options = {}) {
const split = num.toString().split('.');
let before = split.shift();
let after = split.length ? split[0] : '';
const delimiter = options.delimiter || ',';
- 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 register
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
register(name: string, desc: string | Option | AnyFn, options?: Option | AnyFn, fn?: AnyFn): void {
if (!name) throw new TypeError('name is required');
if (!fn) {
if (options) {
- 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 tocHelper
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tocHelper(str: string, options: Options = {}) {
options = Object.assign({
min_depth: 1,
max_depth: 6,
class: 'toc',
Function listTagsHelper
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function listTagsHelper(this: LocalsType, tags?: Query<TagSchema> | Options, options?: Options) {
if (!options && (!tags || !Object.prototype.hasOwnProperty.call(tags, 'length'))) {
options = tags as Options;
tags = this.site.tags;
}
Function newPostPathFilter
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function newPostPathFilter(this: Hexo, data: PostSchema = {}, replace?: boolean): Promise<string> {
const sourceDir = this.source_dir;
const draftDir = join(sourceDir, '_drafts');
const postDir = join(sourceDir, '_posts');
const { config } = this;
- 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"