Showing 105 of 173 total issues
Avoid deeply nested control flow statements. Open
for (; a <= b; a++) {
mark.push(a);
}
Avoid deeply nested control flow statements. Open
if (swig_tag_name !== '' && str.includes(`end${swig_tag_name}`)) {
state = STATE_SWIG_FULL_TAG;
} else {
swig_tag_name = '';
state = STATE_PLAINTEXT;
Avoid deeply nested control flow statements. Open
if (!reservedKeys[key]) filenameData[key] = data[key];
Avoid deeply nested control flow statements. Open
if (char === '}' && next_char === '}') {
idx++;
state = STATE_PLAINTEXT;
output += PostRenderEscape.escapeContent(this.stored, 'swig', `{{${buffer}}}`);
buffer = '';
Consider simplifying this complex logical expression. Open
if (typeof options.class !== 'undefined') {
if (typeof options.class === 'string') {
className = options.class;
} else {
className = 'tag';
Function readDirWalker
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function readDirWalker(ctx: Hexo, base: string, results: any[], ignore: any, prefix: string): BlueBirdPromise<any> {
Function makeFeedTag
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function makeFeedTag(this: LocalsType, path?: string, options: Options = {}, configFeed?: any, configTitle?: string) {
Function process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const process = (name: string, ctx: Hexo) => {
return Promise.filter(ctx.model(name).toArray(), (asset: Document<AssetSchema>) => exists(asset.source).tap(exist => {
if (!exist) return asset.remove();
})).map((asset: Document<AssetSchema>) => {
const { source } = asset;
- 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 i18nLocalsFilter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function i18nLocalsFilter(this: Hexo, locals: LocalsType): void {
const { i18n } = this.theme;
const { config } = this;
const i18nDir = config.i18n_dir;
const { page } = locals;
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
register(name: string, output: string, fn: StoreFunction | StoreSyncFunction, sync?: boolean) {
if (!name) throw new TypeError('name is required');
if (!output) throw new TypeError('output is required');
if (typeof fn !== 'function') throw new TypeError('fn must be a function');
- 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 toArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function toArray(value) {
if (Array.isArray(value)) {
// Return if given value is an Array
return value;
} else if (typeof value.toArray === 'function') {
- 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 listPostsHelper
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function listPostsHelper(this: LocalsType, posts?: Query<PostSchema> | Options, options?: Options) {
if (!options && (!posts || !Object.prototype.hasOwnProperty.call(posts, 'length'))) {
options = posts as Options;
posts = this.site.posts;
}
- 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 render
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
render(source: string, data: RenderData = {}, callback?: NodeJSLikeCallback<never>) {
const ctx = this.context;
const { config } = ctx;
const { tag } = ctx.extend;
const ext = data.engine || (source ? extname(source) : '');
- 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 _getPageType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_getPageType(pageLocals): string {
let currentType = 'default';
if (pageLocals.__index) currentType = 'home';
if (pageLocals.__post) currentType = 'post';
if (pageLocals.__page) currentType = 'page';
- 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 too many return
statements within this function. Open
return result;
Avoid too many return
statements within this function. Open
return postAsset.remove();
Avoid too many return
statements within this function. Open
return Object.values(value);
Avoid too many return
statements within this function. Open
return [];
Function _injector
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_injector(input: string, pattern: string | RegExp, flag: Entry, isBegin = true, currentType: string): string {
if (input.includes(`hexo injector ${flag}`)) return input;
const code = this.cache.apply(`${flag}-${currentType}-code`, () => {
const content = currentType === 'default' ? this.getText(flag, 'default') : this.getText(flag, currentType) + this.getText(flag, 'default');
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
register(type: string | StoreFunction, fn?: StoreFunction | number, priority?: number): void {
if (!priority) {
if (typeof type === 'function') {
priority = fn as number;
fn = type;
- 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"