hexojs/hexo-cli

View on GitHub

Showing 8 of 8 total issues

Function register has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  register(name: string, desc: string | Options | Callback, options?: Options | Callback, fn?: Callback) {
    if (!name) throw new TypeError('name is required');

    if (!fn) {
      if (options) {
Severity: Minor
Found in lib/extend/console.ts - About 2 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 initConsole has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function initConsole(this: Context, args: InitArgs) {
  args = Object.assign({ install: true, clone: true }, args);

  const baseDir = this.base_dir;
  const target = args._[0] ? resolve(baseDir, args._[0]) : baseDir;
Severity: Major
Found in lib/console/init.ts - About 2 hrs to fix

    Function initConsole has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    async function initConsole(this: Context, args: InitArgs) {
      args = Object.assign({ install: true, clone: true }, args);
    
      const baseDir = this.base_dir;
      const target = args._[0] ? resolve(baseDir, args._[0]) : baseDir;
    Severity: Minor
    Found in lib/console/init.ts - About 2 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 entry has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function entry(cwd = process.cwd(), args) {
      args = camelCaseKeys(args || minimist(process.argv.slice(2), { string: ['_', 'p', 'path', 's', 'slug'] }));
    
      let hexo = new Context(cwd, args);
      let { log } = hexo;
    Severity: Minor
    Found in lib/hexo.ts - About 1 hr to fix

      Function register has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        register(name: string, desc: string | Options | Callback, options?: Options | Callback, fn?: Callback) {
          if (!name) throw new TypeError('name is required');
      
          if (!fn) {
            if (options) {
      Severity: Minor
      Found in lib/extend/console.ts - About 1 hr to fix

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

        async function versionConsole(this: Context) {
          const { versions, platform } = process;
          const keys = Object.keys(versions);
        
          if (this.version) {
        Severity: Minor
        Found in lib/console/version.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 helpConsole has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function helpConsole(this: Context, args: HelpArgs) {
          if (args.v || args.version) {
            return this.call('version');
          } else if (args.consoleList) {
            return printConsoleList(this.extend.console.list());
        Severity: Minor
        Found in lib/console/help.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

        Avoid too many return statements within this function.
        Open

          return printAllHelp(this.extend.console.list());
        Severity: Major
        Found in lib/console/help.ts - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language