@@ -119,15 +119,15 @@ var categories = function(checkName) {
119119// structured way, so we extract them from strings. That means that any check categorized
120120// as Complexity MUST have a rule here to extract value.
121121//
122- // If this function fails to find a matching string segment, it will return `undefined` .
122+ // If a matching string segment cannot be found, `null` will be returned .
123123var messageMetricValue = function ( message ) {
124124 var match = null ;
125125 switch ( message . ruleId ) {
126126 case "complexity" :
127- match = message . message ( / c o m p l e x i t y o f ( \d + ) / ) ;
127+ match = message . message . match ( / c o m p l e x i t y o f ( \d + ) / ) ;
128128 break ;
129129 case "max-statements" :
130- match = message . message ( " /too many statements \((\d+)\)/" ) ;
130+ match = message . message . match ( / t o o m a n y s t a t e m e n t s \( ( \d + ) \) / ) ;
131131 break ;
132132 }
133133 if ( null !== match ) {
@@ -136,13 +136,17 @@ var messageMetricValue = function(message) {
136136 return null ;
137137} ;
138138
139- var remediationPoints = function ( checkName , message ) {
140- if ( categories ( checkName ) === [ "Complexity" ] ) {
139+ var metricThreshold = function ( ruleId , eslintConfig ) {
140+ return eslintConfig . rules [ ruleId ] [ 1 ] ;
141+ } ;
142+
143+ var remediationPoints = function ( checkName , message , eslintConfig ) {
144+ if ( categories ( checkName ) [ 0 ] === "Complexity" ) {
141145 // (@base_cost + (overage * @cost_per))*1_000_000
142146 // cost_per: 0.1, base: 1
143147 var costPer = 70000
144148 , points = 1000000
145- , threshold = 10 // TODO: Get this from the eslintrc
149+ , threshold = metricThreshold ( message . ruleId , eslintConfig )
146150 , overage
147151 , metricValue ;
148152
0 commit comments