zhulux/lutool-build

View on GitHub

Showing 7 of 7 total issues

Function getWebpackCommonConfig has 124 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function getWebpackCommonConfig(args) {
  const pkgPath = join(args.cwd, 'package.json');
  const pkg = existsSync(pkgPath) ? require(pkgPath) : {};

  const jsFileName = args.hash ? '[name]-[chunkhash].js' : '[name].js';
Severity: Major
Found in src/getWebpackCommonConfig.js - About 4 hrs to fix

    Function build has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function build(args, callback) {
      // Get config.
      let webpackConfig = getWebpackConfig(args);
      webpackConfig = Array.isArray(webpackConfig) ? webpackConfig : [webpackConfig];
    
    
    Severity: Minor
    Found in src/build.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 build has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function build(args, callback) {
      // Get config.
      let webpackConfig = getWebpackConfig(args);
      webpackConfig = Array.isArray(webpackConfig) ? webpackConfig : [webpackConfig];
    
    
    Severity: Major
    Found in src/build.js - About 3 hrs to fix

      Function getWebpackConfig has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getWebpackConfig(args) {
        let webpackConfig = getWebpackCommonConfig(args);
      
        webpackConfig.plugins = webpackConfig.plugins || [];
      
      
      Severity: Minor
      Found in src/build.js - About 1 hr to fix

        Function doneHandler has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function doneHandler(err, stats) {
            if (args.json) {
              const filename = typeof args.json === 'boolean' ? 'build-bundle.json' : args.json;
              const jsonPath = join(fileOutputPath, filename);
              writeFileSync(jsonPath, JSON.stringify(stats.toJson()), 'utf-8');
        Severity: Minor
        Found in src/build.js - About 1 hr to fix

          Function getWebpackConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function getWebpackConfig(args) {
            let webpackConfig = getWebpackCommonConfig(args);
          
            webpackConfig.plugins = webpackConfig.plugins || [];
          
          
          Severity: Minor
          Found in src/build.js - About 55 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 getWebpackCommonConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function getWebpackCommonConfig(args) {
            const pkgPath = join(args.cwd, 'package.json');
            const pkg = existsSync(pkgPath) ? require(pkgPath) : {};
          
            const jsFileName = args.hash ? '[name]-[chunkhash].js' : '[name].js';
          Severity: Minor
          Found in src/getWebpackCommonConfig.js - 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

          Severity
          Category
          Status
          Source
          Language