Showing 161 of 161 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 exports has 148 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 openGraphHelper has a Cognitive Complexity of 35 (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 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

      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

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

      function listArchivesHelper(options = {}) {
        const { config } = this;
        const archiveDir = config.archive_dir;
        const { timezone } = config;
        const lang = this.page.lang || this.page.language || config.language;
      Severity: Minor
      Found in lib/plugins/helper/list_archives.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

      function cssHelper(...args) {
        return args.reduce((result, path, i) => {
          if (i) result += '\n';
      
          if (Array.isArray(path)) {
      Severity: Major
      Found in lib/plugins/helper/css.js and 1 other location - About 4 hrs to fix
      lib/plugins/helper/js.js on lines 3..13

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

      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

      function jsHelper(...args) {
        return args.reduce((result, path, i) => {
          if (i) result += '\n';
      
          if (Array.isArray(path)) {
      Severity: Major
      Found in lib/plugins/helper/js.js and 1 other location - About 4 hrs to fix
      lib/plugins/helper/css.js on lines 3..13

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

      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 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('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 116..123

      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('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 69..76

      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

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

        Deployer.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/deployer.js and 1 other location - About 4 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 116.

        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

        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 4 hrs to fix
        lib/extend/deployer.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 116.

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

        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

          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 39..47

        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

        File index.js has 329 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 3 hrs to fix

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

            module.exports = ctx => {
              const { config } = ctx;
            
              function makeUrl(path) {
                if (path[0] === '#' || path.startsWith('//')) {
            Severity: Minor
            Found in lib/plugins/tag/img.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 exports has 93 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
              Severity
              Category
              Status
              Source
              Language