SungardAS/condensation

View on GitHub

Showing 39 of 39 total issues

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

module.exports = function fnGetAZs(region, options) {
  options = _.merge({hash: {}}, options);

  region = cValue(region, options);

Severity: Major
Found in lib/condensation/template-helpers/functions/fnGetAZs.js and 1 other location - About 1 hr to fix
lib/condensation/template-helpers/functions/fnImportValue.js on lines 13..20

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

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 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function(s3opts,distPath,awsS3) {
  var self = this;

  var templateData = {};
  var urlString = [awsS3.endpoint.href,path.posix.join(s3opts.aws.bucket,s3opts.prefix)].join('');
Severity: Minor
Found in lib/condensation/tasks/build.js - 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 validator has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function validator(opts) {
  var cloudformation = new AWS.CloudFormation(opts);
  // creating a stream through which each file will pass
  var stream = through.obj(function(file, enc, cb) {
    var retry = backoff.exponential();
Severity: Minor
Found in lib/gulp-plugins/gulp-cf-validate.js - About 1 hr to fix

    Function loadHelper has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var loadHelper = function(helperDefinition,options) {
      var cOpts = _.merge({
        handlebars: Handlebars,
        projectDir: process.cwd(),
        particleLoader: null,
    Severity: Minor
    Found in lib/condensation/loaders/template-helper-loader.js - About 1 hr to fix

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

      var ParticleLoader = function(options) {
        this.root = options.root;
        this.registry = {};
        this.typeMap = {
          'asset': 'assets',
      Severity: Minor
      Found in lib/condensation/loaders/particle-loader.js - About 1 hr to fix

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

          var stream = through.obj(function(file, enc, cb) {
            var retry = backoff.exponential();
            retry.failAfter(20);
        
            retry.on('ready', function(number,delay) {
        Severity: Minor
        Found in lib/gulp-plugins/gulp-cf-validate.js - About 1 hr to fix

          Function parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.parse = function parse(str,options) {
            var opts = _.merge({}, options);
          
          
            if (_.isPlainObject(str)) {
          Severity: Minor
          Found in lib/condensation/util.js - 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 cValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function cValue(str,options) {
            options = _.merge({
              hash: {
                forceNumber: false
              }
          Severity: Minor
          Found in lib/condensation/template-helpers/cValue.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

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

          var processTemplate = function(conf) {
          
            var engine = conf.cOpts.handlebars;
            var templateContent = '';
          
          
          Severity: Minor
          Found in lib/condensation/template-helpers/sections/_buildHelper.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

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

          var helper = function(cModule,pPath,hArgs,hOpts,cOpts) {
          Severity: Minor
          Found in lib/condensation/template-helpers/set.js - About 35 mins to fix

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

            var helper = function (cModule,pPath,hArgs,hOpts,cOpts) {
            Severity: Minor
            Found in lib/condensation/template-helpers/templateS3Url.js - About 35 mins to fix

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

              var helper = function layout(cModule,pPath,hArgs,hOpts,cOpts) {
              Severity: Minor
              Found in lib/condensation/template-helpers/layout.js - About 35 mins to fix

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

                var helper = function (cModule,pPath,hArgs,hOpts,cOpts) {
                Severity: Minor
                Found in lib/condensation/template-helpers/requireAssets.js - About 35 mins to fix

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

                  var helper = function helper(cModule,pPath,hArgs,hOpts,cOpts) {
                  Severity: Minor
                  Found in lib/condensation/template-helpers/helper.js - About 35 mins to fix

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

                      var helper = function(cModule,pPath,hArgs,hOpts,cOpts) {
                    Severity: Minor
                    Found in lib/condensation/template-helpers/sections/_buildHelper.js - About 35 mins to fix

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

                      var helper = function assetPath(cModule,pPath,hArgs,hOpts,cOpts) {
                      Severity: Minor
                      Found in lib/condensation/template-helpers/assetPath.js - About 35 mins to fix

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

                        var helper = function assetS3Url(cModule,pPath,hArgs,hOpts,cOpts) {
                        Severity: Minor
                        Found in lib/condensation/template-helpers/assetS3Url.js - About 35 mins to fix

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

                          var helper = function layout(cModule,pPath,hArgs,hOpts,cOpts) {
                          
                            var engine = cOpts.handlebars;
                            var data = engine.createFrame(hOpts.data || {});
                            data._isLayout = true;
                          Severity: Minor
                          Found in lib/condensation/template-helpers/layout.js - 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 dump has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.dump = function dump(opts) {
                          
                            var format = "json";
                          
                            if (opts.format) {
                          Severity: Minor
                          Found in lib/condensation/util.js - 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

                          Severity
                          Category
                          Status
                          Source
                          Language