Showing 105 of 173 total issues

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

      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

        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

          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

            Function readDirWalker has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function readDirWalker(ctx: Hexo, base: string, results: any[], ignore: any, prefix: string): BlueBirdPromise<any> {
            Severity: Minor
            Found in lib/box/index.ts - About 35 mins to fix

              Function makeFeedTag has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function makeFeedTag(this: LocalsType, path?: string, options: Options = {}, configFeed?: any, configTitle?: string) {
              Severity: Minor
              Found in lib/plugins/helper/feed_tag.ts - About 35 mins to fix

                Function process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                const process = (name: string, ctx: Hexo) => {
                  return Promise.filter(ctx.model(name).toArray(), (asset: Document<AssetSchema>) => exists(asset.source).tap(exist => {
                    if (!exist) return asset.remove();
                  })).map((asset: Document<AssetSchema>) => {
                    const { source } = asset;
                Severity: Minor
                Found in lib/plugins/generator/asset.ts - About 35 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 i18nLocalsFilter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function i18nLocalsFilter(this: Hexo, locals: LocalsType): void {
                  const { i18n } = this.theme;
                  const { config } = this;
                  const i18nDir = config.i18n_dir;
                  const { page } = locals;
                Severity: Minor
                Found in lib/plugins/filter/template_locals/i18n.ts - About 35 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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  register(name: string, output: string, fn: StoreFunction | StoreSyncFunction, sync?: boolean) {
                    if (!name) throw new TypeError('name is required');
                    if (!output) throw new TypeError('output is required');
                    if (typeof fn !== 'function') throw new TypeError('fn must be a function');
                
                
                Severity: Minor
                Found in lib/extend/renderer.ts - About 35 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 toArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function toArray(value) {
                  if (Array.isArray(value)) {
                    // Return if given value is an Array
                    return value;
                  } else if (typeof value.toArray === 'function') {
                Severity: Minor
                Found in lib/plugins/renderer/nunjucks.ts - About 35 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 listPostsHelper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function listPostsHelper(this: LocalsType, posts?: Query<PostSchema> | Options, options?: Options) {
                  if (!options && (!posts || !Object.prototype.hasOwnProperty.call(posts, 'length'))) {
                    options = posts as Options;
                    posts = this.site.posts;
                  }
                Severity: Minor
                Found in lib/plugins/helper/list_posts.ts - About 35 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  render(source: string, data: RenderData = {}, callback?: NodeJSLikeCallback<never>) {
                    const ctx = this.context;
                    const { config } = ctx;
                    const { tag } = ctx.extend;
                    const ext = data.engine || (source ? extname(source) : '');
                Severity: Minor
                Found in lib/hexo/post.ts - About 35 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 _getPageType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  _getPageType(pageLocals): string {
                    let currentType = 'default';
                    if (pageLocals.__index) currentType = 'home';
                    if (pageLocals.__post) currentType = 'post';
                    if (pageLocals.__page) currentType = 'page';
                Severity: Minor
                Found in lib/extend/injector.ts - About 35 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 too many return statements within this function.
                Open

                  return result;
                Severity: Major
                Found in lib/hexo/render.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return postAsset.remove();
                  Severity: Major
                  Found in lib/plugins/processor/post.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return Object.values(value);
                    Severity: Major
                    Found in lib/plugins/renderer/nunjucks.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return [];
                      Severity: Major
                      Found in lib/plugins/renderer/nunjucks.ts - About 30 mins to fix

                        Function _injector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _injector(input: string, pattern: string | RegExp, flag: Entry, isBegin = true, currentType: string): string {
                            if (input.includes(`hexo injector ${flag}`)) return input;
                        
                            const code = this.cache.apply(`${flag}-${currentType}-code`, () => {
                              const content = currentType === 'default' ? this.getText(flag, 'default') : this.getText(flag, currentType) + this.getText(flag, 'default');
                        Severity: Minor
                        Found in lib/extend/injector.ts - About 25 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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          register(type: string | StoreFunction, fn?: StoreFunction | number, priority?: number): void {
                            if (!priority) {
                              if (typeof type === 'function') {
                                priority = fn as number;
                                fn = type;
                        Severity: Minor
                        Found in lib/extend/filter.ts - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language