0

I have following code:

return _.map(_.compact([
                $scope.status() ? false : "status",
                ($scope.evidenceLevel || {}).id ? false : "evidence_level",
                ($scope.association || {}).id ? false : "association",
                $scope.predictiveStatement ? false : "predictive_statement",
                $scope.evidenceStatement ? false : "evidence_statement",
                ($scope.hasIncludedReference() || isReferred()) ? false : "reference"
            ]), myFunction);

Sonarqube thinks that this method too complicated (complexity is 11, max allowed is 10), is there any standard function for such code - ($scope.association || {}).id?

ruslan5t
  • 257
  • 3
  • 16

1 Answers1

0

You can eventually use _.defaults. Supported by Underscore and probably by lodash.

http://underscorejs.org/#defaults

Neozaru
  • 1,109
  • 1
  • 10
  • 25