Showing 172 of 172 total issues

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 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

      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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              return loadDatabase(this).then(() => {
                this.log.info('Start processing');
          
                return Promise.all([
                  this.source.watch(),
          Severity: Major
          Found in lib/hexo/index.ts and 1 other location - About 1 hr to fix
          lib/hexo/index.ts on lines 504..514

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              for (let j = 0, lenj = item.length; j < lenj; j++) {
                const seg = item[j];
                cursor[seg] = cursor[seg] || {};
                cursor = cursor[seg];
              }
          Severity: Major
          Found in lib/plugins/console/list/route.ts and 1 other location - About 1 hr to fix
          lib/plugins/console/config.ts on lines 60..64

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              return loadDatabase(this).then(() => {
                this.log.info('Start processing');
          
                return Promise.all([
                  this.source.process(),
          Severity: Major
          Found in lib/hexo/index.ts and 1 other location - About 1 hr to fix
          lib/hexo/index.ts on lines 530..547

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            for (let i = 0, len = split.length; i < len; i++) {
              const name = split[i];
              cursor[name] = cursor[name] || {};
              cursor = cursor[name];
            }
          Severity: Major
          Found in lib/plugins/console/config.ts and 1 other location - About 1 hr to fix
          lib/plugins/console/list/route.ts on lines 25..29

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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 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 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

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                        for (let i = 0, len = keys.length; i < len; i++) {
                          const key = keys[i];
                          if (!reservedKeys[key]) filenameData[key] = data[key];
                        }
                Severity: Major
                Found in lib/plugins/filter/new_post_path.ts and 2 other locations - About 1 hr to fix
                lib/plugins/console/new.ts on lines 56..59
                lib/plugins/processor/post.ts on lines 107..110

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                const og = (name: string, content?: string, escape?: boolean) => {
                  if (escape !== false && typeof content === 'string') {
                    content = escapeHTML(content);
                  }
                
                
                Severity: Major
                Found in lib/plugins/helper/open_graph.ts and 1 other location - About 1 hr to fix
                lib/plugins/helper/open_graph.ts on lines 38..45

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    for (let i = 0, len = keys.length; i < len; i++) {
                      const key = keys[i];
                      if (!preservedKeys[key]) data[key] = info[key];
                    }
                Severity: Major
                Found in lib/plugins/processor/post.ts and 2 other locations - About 1 hr to fix
                lib/plugins/console/new.ts on lines 56..59
                lib/plugins/filter/new_post_path.ts on lines 75..78

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                const meta = (name: string, content: string | URL, escape?: boolean) => {
                  if (escape !== false && typeof content === 'string') {
                    content = escapeHTML(content);
                  }
                
                
                Severity: Major
                Found in lib/plugins/helper/open_graph.ts and 1 other location - About 1 hr to fix
                lib/plugins/helper/open_graph.ts on lines 47..54

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  for (let i = 0, len = keys.length; i < len; i++) {
                    const key = keys[i];
                    if (!reservedKeys[key]) data[key] = args[key];
                  }
                Severity: Major
                Found in lib/plugins/console/new.ts and 2 other locations - About 1 hr to fix
                lib/plugins/filter/new_post_path.ts on lines 75..78
                lib/plugins/processor/post.ts on lines 107..110

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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 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

                Severity
                Category
                Status
                Source
                Language