Showing 105 of 173 total issues
Function linkTag
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function linkTag(args: string[]) {
let url = '';
const text = [];
let external = false;
let title = '';
Function createLoadThemeRoute
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createLoadThemeRoute = function(generatorResult: NormalPageGenerator | NormalPostGenerator, locals: LocalsType, ctx: Hexo) {
const { log, theme } = ctx;
const { path, cache: useCache } = locals;
const layout: string[] = [...new Set(castArray(generatorResult.layout))];
Function _generateLocals
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_generateLocals() {
const { config, env, theme, theme_dir } = this;
const ctx = { config: { url: this.config.url } };
const localsObj = this.locals.toObject() as SiteLocals;
Function parseFooter
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const parseFooter = (args: string[], ctx: Hexo) => {
const str = args.join(' ');
if (!str) return '';
let author = '';
Function set
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
set(path: string, data: any): this {
if (typeof path !== 'string') throw new TypeError('path must be a string!');
if (data == null) throw new TypeError('data is required!');
let obj: Data;
- 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 addHierarchy
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const addHierarchy = (catHierarchy: string | string[]) => {
const parentIds = [];
if (!Array.isArray(catHierarchy)) catHierarchy = [catHierarchy];
// Don't use "Promise.map". It doesn't run in series.
// MUST USE "Promise.each".
Function parseFilename
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseFilename(config: string, path: string) {
config = config.substring(0, config.length - extname(config).length);
path = path.substring(0, path.length - extname(path).length);
if (!permalink || permalink.rule !== config) {
Function scanAssetDir
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scanAssetDir(ctx: Hexo, post) {
if (!ctx.config.post_asset_folder) return;
const assetDir = post.asset_dir;
const baseDir = ctx.base_dir;
Function postLinkTag
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function postLinkTag(args: string[]) {
let slug = args.shift();
if (!slug) {
throw new Error(`Post not found: "${slug}" doesn't exist for {% post_link %}`);
}
Function prepareFrontMatter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const prepareFrontMatter = (data: any, jsonMode: boolean) => {
for (const [key, item] of Object.entries(data)) {
if (moment.isMoment(item)) {
data[key] = item.utc().format('YYYY-MM-DD HH:mm:ss');
} else if (moment.isDate(item)) {
- 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 newConsole
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function newConsole(this: Hexo, args: NewArgs) {
const path = args.p || args.path;
let title: string;
if (args._.length) {
title = args._.pop();
- 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 linkTag
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function linkTag(args: string[]) {
let url = '';
const text = [];
let external = false;
let title = '';
- 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 paginatorHelper
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function paginatorHelper(this: LocalsType, options: Options = {}) {
options = Object.assign({
base: this.page.base || '',
current: this.page.current || 0,
format: `${this.config.pagination_dir}/%d/`,
- 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 localeToTerritory
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const localeToTerritory = moize.shallow(str => {
if (str.length === 2 && localeMap[str]) return localeMap[str];
if (str.length === 5) {
let territory = [];
- 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
Avoid deeply nested control flow statements. Open
if (isNonWhiteSpaceChar(char)) {
if (!swig_tag_name_begin && !swig_tag_name_end) {
swig_tag_name_begin = true;
}
Function externalLinkFilter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function externalLinkFilter(this: Hexo, data: RenderData): void {
if (!EXTERNAL_LINK_POST_ENABLED) return;
const { external_link, url } = this.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
Avoid deeply nested control flow statements. Open
} else if (state === STATE_SWIG_COMMENT) { // From swig back to plain text
if (char === '#' && next_char === '}') {
idx++;
state = STATE_PLAINTEXT;
buffer = '';
Avoid deeply nested control flow statements. Open
if (b < a) { // switch a & b
const temp = a;
a = b;
b = temp;
}
Function paginationPartShow
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const paginationPartShow = (tags, options, ctx: LocalsType) => {
const {
current,
total,
space,
- 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
Avoid deeply nested control flow statements. Open
if (Number.isNaN(a) || Number.isNaN(b)) continue;