Showing 106 of 175 total issues
Function imgTag
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function imgTag(args: string[]) {
const classes = [];
let src, width, height, title, alt;
// Find image URL and class name
Function listCategoriesHelper
has a Cognitive Complexity of 12 (exceeds 5 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;
}
- 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 35 lines of code (exceeds 25 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;
}
Function render
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(data: StoreFunctionData, options?: any | NodeJSLikeCallback<any>, callback?: NodeJSLikeCallback<any>): Promise<any> {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Function register
has 34 lines of code (exceeds 25 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) {
Function numberFormatHelper
has 34 lines of code (exceeds 25 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 || ',';
Consider simplifying this complex logical expression. Open
} else if (info && info.year && (info.month || info.i_month) && (info.day || info.i_day)) {
data.date = new Date(
info.year,
parseInt(info.month || info.i_month, 10) - 1,
parseInt(info.day || info.i_day, 10)
Function _read
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
_read(): boolean {
const data = this._data;
if (typeof data !== 'function') {
const bufferData = this._toBuffer(data);
Function _processFile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
_processFile(type: string, path: string): BlueBirdPromise<void> | BlueBirdPromise<string> {
if (this._processingFiles[path]) {
return BlueBirdPromise.resolve();
}
Function paginationPartShow
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const paginationPartShow = (tags, options, ctx: LocalsType) => {
const {
current,
total,
space,
Function processAsset
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processAsset(ctx: Hexo, file: _File) {
const PostAsset = ctx.model('PostAsset');
const Post = ctx.model('Post');
const id = file.source.substring(ctx.base_dir.length);
const postAsset = PostAsset.findById(id);
Function highlightFilter
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function highlightFilter(this: Hexo, code: string, options: Options) {
const hljsCfg = this.config.highlight || {} as any;
const line_threshold = options.line_threshold || hljsCfg.line_threshold || 0;
const shouldUseLineNumbers = typeof options.line_number === 'undefined' ? hljsCfg.line_number : options.line_number;
const surpassesLineThreshold = options.lines_length > line_threshold;
Function _bindLocals
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_bindLocals(): void {
const db = this.database;
const { locals } = this;
locals.set('posts', () => {
Function _parseArgs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_parseArgs(parser, nodes, lexer) {
const tag = parser.nextToken();
const node = new nodes.NodeList(tag.lineno, tag.colno);
const argarray = new nodes.Array(tag.lineno, tag.colno);
- 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 highlightFilter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function highlightFilter(this: Hexo, code: string, options: Options) {
const hljsCfg = this.config.highlight || {} as any;
const line_threshold = options.line_threshold || hljsCfg.line_threshold || 0;
const shouldUseLineNumbers = typeof options.line_number === 'undefined' ? hljsCfg.line_number : options.line_number;
const surpassesLineThreshold = options.lines_length > line_threshold;
- 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 renderSync
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
renderSync(data: StoreFunctionData, options = {}): any {
if (!data) throw new TypeError('No input file or string!');
const ctx = this.context;
- 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 writeFile
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
writeFile(path: string, force?: boolean): Promise<any> {
const { route, log } = this.context;
const publicDir = this.context.public_dir;
const Cache = this.context.model('Cache');
const dataStream = this.wrapDataStream(route.get(path));
Function hierarchicalList
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const hierarchicalList = (level: number, parent?: any) => {
let result = '';
prepareQuery(parent).forEach((cat: CategorySchema) => {
let child;
Function _precompile
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_precompile(): void {
const render = this._render;
const ctx = render.context;
const ext = extname(this.path);
const renderer = render.getRenderer(ext);
Function firstGenerate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
firstGenerate(): Promise<void> {
const { concurrency } = this;
const { route, log } = this.context;
const publicDir = this.context.public_dir;
const Cache = this.context.model('Cache');