Showing 106 of 175 total issues

Function newPostPathFilter has 64 lines of code (exceeds 25 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;
Severity: Major
Found in lib/plugins/filter/new_post_path.ts - About 2 hrs to fix

    Function processPage has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function processPage(ctx: Hexo, file: _File) {
      const Page = ctx.model('Page');
      const { path } = file;
      const doc = Page.findOne({source: path});
      const { config } = ctx;
    Severity: Major
    Found in lib/plugins/processor/asset.ts - About 2 hrs to fix

      Function render has 57 lines of code (exceeds 25 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) : '');
      Severity: Major
      Found in lib/hexo/post.ts - About 2 hrs to fix

        Function tagcloudHelper has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function tagcloudHelper(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;
          }
        Severity: Major
        Found in lib/plugins/helper/tagcloud.ts - About 2 hrs to fix

          Function constructor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(base = process.cwd(), args: Args = {}) {
              super();
          
              this.base_dir = base + sep;
              this.public_dir = join(base, 'public') + sep;
          Severity: Major
          Found in lib/hexo/index.ts - About 2 hrs to fix

            Function postPermalinkFilter has 54 lines of code (exceeds 25 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;
            Severity: Major
            Found in lib/plugins/filter/post_permalink.ts - About 2 hrs to fix

              File post.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { toDate, timezone, isExcludedFile, isTmpFile, isHiddenFile, isMatch } from './common';
              import Promise from 'bluebird';
              import { parse as yfm } from 'hexo-front-matter';
              import { extname, join, posix, sep } from 'path';
              import { stat, listDir } from 'hexo-fs';
              Severity: Minor
              Found in lib/plugins/processor/post.ts - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                      if (jsonMode || item.includes(':') || item.startsWith('#') || item.startsWith('!!')
                      || item.includes('{') || item.includes('}') || item.includes('[') || item.includes(']')
                      || item.includes('\'') || item.includes('"')) data[key] = `"${item.replace(/"/g, '\\"')}"`;
                Severity: Critical
                Found in lib/hexo/post.ts - About 2 hrs to fix

                  Function paginatorHelper has 49 lines of code (exceeds 25 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/`,
                  Severity: Minor
                  Found in lib/plugins/helper/paginator.ts - About 1 hr to fix

                    Function multiConfigPath has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export = (ctx: Hexo) => function multiConfigPath(base: string, configPaths?: string, outputDir?: string): string {
                      const { log } = ctx;
                      const defaultPath = join(base, '_config.yml');
                    
                      if (!configPaths) {
                    Severity: Minor
                    Found in lib/hexo/multi_config_path.ts - About 1 hr to fix

                      Function listTagsHelper has a Cognitive Complexity of 15 (exceeds 5 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;
                        }
                      Severity: Minor
                      Found in lib/plugins/helper/list_tags.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 parseFooter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const parseFooter = (args: string[], ctx: Hexo) => {
                        const str = args.join(' ');
                        if (!str) return '';
                      
                        let author = '';
                      Severity: Minor
                      Found in lib/plugins/tag/blockquote.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 includeCodeTag has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export = (ctx: Hexo) => function includeCodeTag(args: string[]) {
                        let codeDir = ctx.config.code_dir;
                        let arg = args.join(' ');
                      
                        // Add trailing slash to codeDir
                      Severity: Minor
                      Found in lib/plugins/tag/include_code.ts - About 1 hr to fix

                        Function backtickCodeBlock has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          return function backtickCodeBlock(data: RenderData): void {
                            const dataContent = data.content;
                        
                            if ((!dataContent.includes('```') && !dataContent.includes('~~~')) || !ctx.extend.highlight.query(ctx.config.syntax_highlighter)) return;
                        
                        
                        Severity: Minor
                        Found in lib/plugins/filter/before_post_render/backtick_code_block.ts - About 1 hr to fix

                          Function register has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            register(name: string, fn: TagFunction, options?: RegisterOptions | boolean):void {
                              if (!name) throw new TypeError('name is required');
                              if (typeof fn !== 'function') throw new TypeError('fn must be a function');
                          
                              if (options == null || typeof options === 'boolean') {
                          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 processAsset has a Cognitive Complexity of 13 (exceeds 5 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

                          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 tagcloudHelper has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function tagcloudHelper(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;
                            }
                          Severity: Minor
                          Found in lib/plugins/helper/tagcloud.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 content has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              data.content = dataContent.replace(rBacktick, ($0, start, $2, _args, _content, end) => {
                                let content = _content.replace(/\n$/, '');
                          
                                // neither highlight or prismjs is enabled, return escaped content directly.
                                if (!ctx.extend.highlight.query(ctx.config.syntax_highlighter)) return escapeSwigTag($0);
                          Severity: Minor
                          Found in lib/plugins/filter/before_post_render/backtick_code_block.ts - About 1 hr to fix

                            Function deployConsole has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function deployConsole(this: Hexo, args: DeployArgs) {
                              let config = this.config.deploy;
                              const deployers = this.extend.deployer.list();
                            
                              if (!config) {
                            Severity: Minor
                            Found in lib/plugins/console/deploy.ts - About 1 hr to fix

                              Function publish has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                publish(data: PostData, replace?: boolean | NodeJSLikeCallback<Result>, callback?: NodeJSLikeCallback<Result>) {
                                  if (!callback && typeof replace === 'function') {
                                    callback = replace;
                                    replace = false;
                                  }
                              Severity: Minor
                              Found in lib/hexo/post.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language