Showing 175 of 175 total issues

Function linkTag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function linkTag(args: string[]) {
  let url = '';
  const text = [];
  let external = false;
  let title = '';
Severity: Minor
Found in lib/plugins/tag/link.ts - About 55 mins 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 prepareFrontMatter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const prepareFrontMatter = (data: any, jsonMode: boolean) => {
  for (const [key, item] of Object.entries(data)) {
    if (moment.isMoment(item)) {
      data[key] = item.utc().format('YYYY-MM-DD HH:mm:ss');
    } else if (moment.isDate(item)) {
Severity: Minor
Found in lib/hexo/post.ts - About 55 mins 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

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;
Severity: Major
Found in lib/hexo/post.ts - About 45 mins to fix

    Function localeToTerritory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const localeToTerritory = moize.shallow(str => {
      if (str.length === 2 && localeMap[str]) return localeMap[str];
    
      if (str.length === 5) {
        let territory = [];
    Severity: Minor
    Found in lib/plugins/helper/open_graph.ts - About 45 mins 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 paginationPartShow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const paginationPartShow = (tags, options, ctx: LocalsType) => {
      const {
        current,
        total,
        space,
    Severity: Minor
    Found in lib/plugins/helper/paginator.ts - About 45 mins 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

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

      if (attrs.class && Array.isArray(attrs.class)) {
        attrs.class = attrs.class.join(' ');
      }
    Severity: Major
    Found in lib/plugins/helper/image_tag.ts and 2 other locations - About 45 mins to fix
    lib/plugins/helper/link_to.ts on lines 40..42
    lib/plugins/helper/mail_to.ts on lines 36..38

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

    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

    Avoid deeply nested control flow statements.
    Open

                if (Number.isNaN(a) || Number.isNaN(b)) continue;
    Severity: Major
    Found in lib/plugins/tag/code.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (isNonWhiteSpaceChar(char)) {
                  if (!swig_tag_name_begin && !swig_tag_name_end) {
                    swig_tag_name_begin = true;
                  }
      
      
      Severity: Major
      Found in lib/hexo/post.ts - About 45 mins to fix

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

          if (attrs.class && Array.isArray(attrs.class)) {
            attrs.class = attrs.class.join(' ');
          }
        Severity: Major
        Found in lib/plugins/helper/mail_to.ts and 2 other locations - About 45 mins to fix
        lib/plugins/helper/image_tag.ts on lines 21..23
        lib/plugins/helper/link_to.ts on lines 40..42

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

        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

        Avoid deeply nested control flow statements.
        Open

                    if (b < a) { // switch a & b
                      const temp = a;
                      a = b;
                      b = temp;
                    }
        Severity: Major
        Found in lib/plugins/tag/code.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                } else if (state === STATE_SWIG_COMMENT) { // From swig back to plain text
                  if (char === '#' && next_char === '}') {
                    idx++;
                    state = STATE_PLAINTEXT;
                    buffer = '';
          Severity: Major
          Found in lib/hexo/post.ts - About 45 mins to fix

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

              addProcessor(pattern: string | RegExp | Pattern | ((...args: any[]) => any), fn: (...args: any[]) => any): void;
            Severity: Minor
            Found in lib/box/index.ts and 1 other location - About 45 mins to fix
            lib/box/index.ts on lines 87..100

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

            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

            Avoid deeply nested control flow statements.
            Open

                        for (; a <= b; a++) {
                          mark.push(a);
                        }
            Severity: Major
            Found in lib/plugins/tag/code.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      if (char === '}' && next_char === '}') {
                        idx++;
                        state = STATE_PLAINTEXT;
                        output += PostRenderEscape.escapeContent(this.stored, 'swig', `{{${buffer}}}`);
                        buffer = '';
              Severity: Major
              Found in lib/hexo/post.ts - About 45 mins to fix

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

                  addProcessor(pattern: string | RegExp | Pattern | ((...args: any[]) => any), fn?: (...args: any[]) => any): void {
                    if (!fn && typeof pattern === 'function') {
                      fn = pattern;
                      pattern = defaultPattern;
                    }
                Severity: Minor
                Found in lib/box/index.ts and 1 other location - About 45 mins to fix
                lib/box/index.ts on lines 86..86

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

                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

                Avoid deeply nested control flow statements.
                Open

                          if (!reservedKeys[key]) filenameData[key] = data[key];
                Severity: Major
                Found in lib/plugins/filter/new_post_path.ts - About 45 mins to fix

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

                    if (attrs.class && Array.isArray(attrs.class)) {
                      attrs.class = attrs.class.join(' ');
                    }
                  Severity: Major
                  Found in lib/plugins/helper/link_to.ts and 2 other locations - About 45 mins to fix
                  lib/plugins/helper/image_tag.ts on lines 21..23
                  lib/plugins/helper/mail_to.ts on lines 36..38

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

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

                  function externalLinkFilter(this: Hexo, data: RenderData): void {
                    if (!EXTERNAL_LINK_POST_ENABLED) return;
                  
                    const { external_link, url } = this.config;
                  
                  
                  Severity: Minor
                  Found in lib/plugins/filter/after_post_render/external_link.ts - About 45 mins 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

                  Consider simplifying this complex logical expression.
                  Open

                    if (typeof options.class !== 'undefined') {
                      if (typeof options.class === 'string') {
                        className = options.class;
                      } else {
                        className = 'tag';
                  Severity: Major
                  Found in lib/plugins/helper/list_tags.ts - About 40 mins to fix

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

                    export = (ctx: Hexo) => {
                      const { filter } = ctx.extend;
                    
                      filter.register('template_locals', require('./i18n'));
                    };
                    Severity: Minor
                    Found in lib/plugins/filter/template_locals/index.ts and 2 other locations - About 40 mins to fix
                    lib/plugins/filter/before_exit/index.ts on lines 3..7
                    lib/plugins/filter/before_generate/index.ts on lines 3..7

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language