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
Severity: Minor
Found in lib/plugins/tag/img.ts - About 1 hr to fix

    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;
      }
    Severity: Minor
    Found in lib/plugins/helper/list_categories.ts - About 1 hr to fix

    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;
      }
    Severity: Minor
    Found in lib/plugins/helper/list_posts.ts - About 1 hr to fix

      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 = {};
          }
      Severity: Minor
      Found in lib/hexo/render.ts - About 1 hr to fix

        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) {
        Severity: Minor
        Found in lib/extend/console.ts - About 1 hr to fix

          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 || ',';
          Severity: Minor
          Found in lib/plugins/helper/number_format.ts - About 1 hr to fix

            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)
            Severity: Critical
            Found in lib/plugins/processor/post.ts - About 1 hr to fix

              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);
              Severity: Minor
              Found in lib/hexo/router.ts - About 1 hr to fix

                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();
                    }
                
                
                Severity: Minor
                Found in lib/box/index.ts - About 1 hr to fix

                  Function paginationPartShow has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const paginationPartShow = (tags, options, ctx: LocalsType) => {
                    const {
                      current,
                      total,
                      space,
                  Severity: Minor
                  Found in lib/plugins/helper/paginator.ts - About 1 hr to fix

                    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);
                    Severity: Minor
                    Found in lib/plugins/processor/post.ts - About 1 hr to fix

                      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;
                      Severity: Minor
                      Found in lib/plugins/highlight/highlight.ts - About 1 hr to fix

                        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', () => {
                        Severity: Minor
                        Found in lib/hexo/index.ts - About 1 hr to fix

                          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);
                          
                          
                          Severity: Minor
                          Found in lib/extend/tag.ts - About 1 hr to fix

                          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;
                          Severity: Minor
                          Found in lib/plugins/highlight/highlight.ts - About 1 hr to fix

                          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;
                          
                          
                          Severity: Minor
                          Found in lib/hexo/render.ts - About 1 hr to fix

                          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));
                          Severity: Minor
                          Found in lib/plugins/console/generate.ts - About 1 hr to fix

                            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;
                            Severity: Minor
                            Found in lib/plugins/helper/list_categories.ts - About 1 hr to fix

                              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);
                              Severity: Minor
                              Found in lib/theme/view.ts - About 1 hr to fix

                                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');
                                Severity: Minor
                                Found in lib/plugins/console/generate.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language