Showing 175 of 175 total issues

Function _read has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _read(): boolean {
    const data = this._data;

    if (typeof data !== 'function') {
      const bufferData = this._toBuffer(data);
Severity: Minor
Found in lib/hexo/router.ts - About 1 hr to fix

    Function _processFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _processFile(type: string, path: string): BlueBirdPromise<void> | BlueBirdPromise<string> {
        if (this._processingFiles[path]) {
          return BlueBirdPromise.resolve();
        }
    
    
    Severity: Minor
    Found in lib/box/index.ts - About 1 hr to fix

      Function paginationPartShow has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const paginationPartShow = (tags, options, ctx: LocalsType) => {
        const {
          current,
          total,
          space,
      Severity: Minor
      Found in lib/plugins/helper/paginator.ts - About 1 hr to fix

        Function processAsset has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processAsset(ctx: Hexo, file: _File) {
          const PostAsset = ctx.model('PostAsset');
          const Post = ctx.model('Post');
          const id = file.source.substring(ctx.base_dir.length);
          const postAsset = PostAsset.findById(id);
        Severity: Minor
        Found in lib/plugins/processor/post.ts - About 1 hr to fix

          Function highlightFilter has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function highlightFilter(this: Hexo, code: string, options: Options) {
            const hljsCfg = this.config.highlight || {} as any;
            const line_threshold = options.line_threshold || hljsCfg.line_threshold || 0;
            const shouldUseLineNumbers = typeof options.line_number === 'undefined' ? hljsCfg.line_number : options.line_number;
            const surpassesLineThreshold = options.lines_length > line_threshold;
          Severity: Minor
          Found in lib/plugins/highlight/highlight.ts - About 1 hr to fix

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

              parse(parser, nodes, lexer) {
                const node = this._parseArgs(parser, nodes, lexer);
                const body = this._parseBody(parser, nodes, lexer);
            
                return new nodes.CallExtensionAsync(this, 'run', node, [body]);
            Severity: Major
            Found in lib/extend/tag.ts and 1 other location - About 1 hr to fix
            lib/extend/tag.ts on lines 76..81

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

            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

              parse(parser, nodes, lexer) {
                const node = this._parseArgs(parser, nodes, lexer);
                const body = this._parseBody(parser, nodes, lexer);
            
                return new nodes.CallExtension(this, 'run', node, [body]);
            Severity: Major
            Found in lib/extend/tag.ts and 1 other location - About 1 hr to fix
            lib/extend/tag.ts on lines 110..115

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

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

              _bindLocals(): void {
                const db = this.database;
                const { locals } = this;
            
                locals.set('posts', () => {
            Severity: Minor
            Found in lib/hexo/index.ts - About 1 hr to fix

              Function _parseArgs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                _parseArgs(parser, nodes, lexer) {
                  const tag = parser.nextToken();
                  const node = new nodes.NodeList(tag.lineno, tag.colno);
                  const argarray = new nodes.Array(tag.lineno, tag.colno);
              
              
              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 highlightFilter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function highlightFilter(this: Hexo, code: string, options: Options) {
                const hljsCfg = this.config.highlight || {} as any;
                const line_threshold = options.line_threshold || hljsCfg.line_threshold || 0;
                const shouldUseLineNumbers = typeof options.line_number === 'undefined' ? hljsCfg.line_number : options.line_number;
                const surpassesLineThreshold = options.lines_length > line_threshold;
              Severity: Minor
              Found in lib/plugins/highlight/highlight.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 renderSync has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                renderSync(data: StoreFunctionData, options = {}): any {
                  if (!data) throw new TypeError('No input file or string!');
              
                  const ctx = this.context;
              
              
              Severity: Minor
              Found in lib/hexo/render.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

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

                  if (typeof item === 'string' || item instanceof String) {
                    let path = item;
                    if (!path.endsWith('.js')) {
                      path += '.js';
                    }
              Severity: Major
              Found in lib/plugins/helper/js.ts and 1 other location - About 1 hr to fix
              lib/plugins/helper/css.ts on lines 12..23

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

              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

                  if (typeof item === 'string' || item instanceof String) {
                    let path = item;
                    if (!path.endsWith('.css')) {
                      path += '.css';
                    }
              Severity: Major
              Found in lib/plugins/helper/css.ts and 1 other location - About 1 hr to fix
              lib/plugins/helper/js.ts on lines 12..23

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

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

                writeFile(path: string, force?: boolean): Promise<any> {
                  const { route, log } = this.context;
                  const publicDir = this.context.public_dir;
                  const Cache = this.context.model('Cache');
                  const dataStream = this.wrapDataStream(route.get(path));
              Severity: Minor
              Found in lib/plugins/console/generate.ts - About 1 hr to fix

                Function hierarchicalList has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const hierarchicalList = (level: number, parent?: any) => {
                    let result = '';
                
                    prepareQuery(parent).forEach((cat: CategorySchema) => {
                      let child;
                Severity: Minor
                Found in lib/plugins/helper/list_categories.ts - About 1 hr to fix

                  Function _precompile has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _precompile(): void {
                      const render = this._render;
                      const ctx = render.context;
                      const ext = extname(this.path);
                      const renderer = render.getRenderer(ext);
                  Severity: Minor
                  Found in lib/theme/view.ts - About 1 hr to fix

                    Function firstGenerate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      firstGenerate(): Promise<void> {
                        const { concurrency } = this;
                        const { route, log } = this.context;
                        const publicDir = this.context.public_dir;
                        const Cache = this.context.model('Cache');
                    Severity: Minor
                    Found in lib/plugins/console/generate.ts - About 1 hr to fix

                      Function linkTag has 30 lines of code (exceeds 25 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 1 hr to fix

                        Function createLoadThemeRoute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const createLoadThemeRoute = function(generatorResult: NormalPageGenerator | NormalPostGenerator, locals: LocalsType, ctx: Hexo) {
                          const { log, theme } = ctx;
                          const { path, cache: useCache } = locals;
                        
                          const layout: string[] = [...new Set(castArray(generatorResult.layout))];
                        Severity: Minor
                        Found in lib/hexo/index.ts - About 1 hr to fix

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

                            Post.pre('remove', data => {
                              const PostTag = ctx.model('PostTag');
                              return PostTag.remove({post_id: data._id});
                            });
                          Severity: Major
                          Found in lib/models/post.ts and 1 other location - About 1 hr to fix
                          lib/models/post.ts on lines 214..217

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

                          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