Showing 174 of 174 total issues

Function exports has 173 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = ctx => {
  function processPost(file) {
    const Post = ctx.model('Post');
    const { path } = file.params;
    const doc = Post.findOne({source: file.path});
Severity: Major
Found in lib/plugins/processor/post.js - About 6 hrs to fix

    Function openGraphHelper has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    function openGraphHelper(options = {}) {
    
      const { config, page } = this;
      const { content } = page;
      let images = options.image || options.images || page.photos || [];
    Severity: Minor
    Found in lib/plugins/helper/open_graph.js - About 6 hrs 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 exports has 145 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = ctx => {
      const Post = new Schema({
        id: String,
        title: {type: String, default: ''},
        date: {
    Severity: Major
    Found in lib/models/post.js - About 5 hrs to fix

      Function listArchivesHelper has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      function listArchivesHelper(options = {}) {
        const { config } = this;
        const archiveDir = config.archive_dir;
        const { timezone } = config;
        const lang = toMomentLocale(this.page.lang || this.page.language || config.language);
      Severity: Minor
      Found in lib/plugins/helper/list_archives.js - About 5 hrs 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 2 locations. Consider refactoring.
      Open

        data = data.replace(/<a([\s]+|[\s]+[^<>]+[\s]+)href=["']([^<>"']+)["'][^<>]*>/gi, (str, _, href) => {
          if (/target=/gi.test(str) || !isExternalLink(href, config.url, config.external_link.exclude)) return str;
      
          if (/rel=/gi.test(str)) {
            str = str.replace(/rel="(.*?)"/gi, (relStr, rel) => {
      Severity: Major
      Found in lib/plugins/filter/after_render/external_link.js and 1 other location - About 5 hrs to fix
      lib/plugins/filter/after_post_render/external_link.js on lines 19..30

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

      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

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

        data.content = data.content.replace(/<a([\s]+|[\s]+[^<>]+[\s]+)href=["']([^<>"']+)["'][^<>]*>/gi, (str, _, href) => {
          if (/target=/gi.test(str) || !isExternalLink(href, config.url, config.external_link.exclude)) return str;
      
          if (/rel=/gi.test(str)) {
            str = str.replace(/rel="(.*?)"/gi, (relStr, rel) => {
      Severity: Major
      Found in lib/plugins/filter/after_post_render/external_link.js and 1 other location - About 5 hrs to fix
      lib/plugins/filter/after_render/external_link.js on lines 19..30

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

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

      function backtickCodeBlock(data) {
        const config = this.config.highlight || {};
        if (!config.enable) return;
        data.content = data.content.replace(rBacktick, ($0, start, $2, _args, content, end) => {
          const args = _args.split('=').shift();
      Severity: Minor
      Found in lib/plugins/filter/before_post_render/backtick_code_block.js - About 5 hrs 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

      File index.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      const Promise = require('bluebird');
      const { sep, join, dirname } = require('path');
      const tildify = require('tildify');
      Severity: Minor
      Found in lib/hexo/index.js - About 4 hrs to fix

        Function exports has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = ctx => {
          function processPost(file) {
            const Post = ctx.model('Post');
            const { path } = file.params;
            const doc = Post.findOne({source: file.path});
        Severity: Minor
        Found in lib/plugins/processor/post.js - About 4 hrs 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

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

          Post.virtual('categories').get(function() {
            const PostCategory = ctx.model('PostCategory');
            const Category = ctx.model('Category');
        
            const ids = PostCategory.find({post_id: this._id}, {lean: true}).map(item => item.category_id);
        Severity: Major
        Found in lib/models/post.js and 1 other location - About 4 hrs to fix
        lib/models/post.js on lines 66..73

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

        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

          Post.virtual('tags').get(function() {
            const PostTag = ctx.model('PostTag');
            const Tag = ctx.model('Tag');
        
            const ids = PostTag.find({post_id: this._id}, {lean: true}).map(item => item.tag_id);
        Severity: Major
        Found in lib/models/post.js and 1 other location - About 4 hrs to fix
        lib/models/post.js on lines 113..120

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

        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 generateConsole has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function generateConsole(args = {}) {
          const force = args.f || args.force;
          const bail = args.b || args.bail;
          const concurrency = args.c || args.concurrency;
          const { route, log } = this;
        Severity: Major
        Found in lib/plugins/console/generate.js - About 4 hrs to fix

          Function openGraphHelper has 104 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function openGraphHelper(options = {}) {
          
            const { config, page } = this;
            const { content } = page;
            let images = options.image || options.images || page.photos || [];
          Severity: Major
          Found in lib/plugins/helper/open_graph.js - About 4 hrs to fix

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

              Category.virtual('posts').get(function() {
                const PostCategory = ctx.model('PostCategory');
            
                const ids = PostCategory.find({category_id: this._id}).map(item => item.post_id);
            
            
            Severity: Major
            Found in lib/models/category.js and 1 other location - About 4 hrs to fix
            lib/models/tag.js on lines 35..43

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

            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

              Tag.virtual('posts').get(function() {
                const PostTag = ctx.model('PostTag');
            
                const ids = PostTag.find({tag_id: this._id}).map(item => item.post_id);
            
            
            Severity: Major
            Found in lib/models/tag.js and 1 other location - About 4 hrs to fix
            lib/models/category.js on lines 44..52

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

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

            module.exports = ctx => function multiConfigPath(base, configPaths, outputDir) {
              const { log } = ctx;
              const defaultPath = join(base, '_config.yml');
            
              if (!configPaths) {
            Severity: Minor
            Found in lib/hexo/multi_config_path.js - About 3 hrs 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 processPost has 95 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function processPost(file) {
                const Post = ctx.model('Post');
                const { path } = file.params;
                const doc = Post.findOne({source: file.path});
                const { config } = ctx;
            Severity: Major
            Found in lib/plugins/processor/post.js - About 3 hrs to fix

              Function exports has 90 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = ctx => {
                function processPage(file) {
                  const Page = ctx.model('Page');
                  const { path } = file;
                  const doc = Page.findOne({source: path});
              Severity: Major
              Found in lib/plugins/processor/asset.js - About 3 hrs to fix

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

                  register(name, fn) {
                    if (!name) throw new TypeError('name is required');
                    if (typeof fn !== 'function') throw new TypeError('fn must be a function');
                
                    if (fn.length > 1) {
                Severity: Major
                Found in lib/extend/deployer.js and 1 other location - About 3 hrs to fix
                lib/extend/migrator.js on lines 17..28

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

                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

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

                Migrator.prototype.register = function(name, fn) {
                  if (!name) throw new TypeError('name is required');
                  if (typeof fn !== 'function') throw new TypeError('fn must be a function');
                
                  if (fn.length > 1) {
                Severity: Major
                Found in lib/extend/migrator.js and 1 other location - About 3 hrs to fix
                lib/extend/deployer.js on lines 18..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 98.

                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