Skip to content

Commit a8155e1

Browse files
committed
COLDBOX-715 #resolve
Elvis operator inconsistencies on Adobe Engines
1 parent 9c1b8f7 commit a8155e1

File tree

7 files changed

+59
-41
lines changed

7 files changed

+59
-41
lines changed

.cflintrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"rule": [],
33
"includes": [
4-
{ "code": "AVOID_USING_STRUCTNEW" },
5-
{ "code": "AVOID_USING_ARRAYNEW" },
64
{ "code": "AVOID_USING_CFINCLUDE_TAG" },
75
{ "code": "AVOID_USING_CFABORT_TAG" },
86
{ "code": "AVOID_USING_CFEXECUTE_TAG" },
@@ -57,8 +55,7 @@
5755
{ "code": "SCOPE_ALLCAPS_NAME" },
5856
{ "code": "VAR_ALLCAPS_NAME" },
5957
{ "code": "VAR_INVALID_NAME" },
60-
{ "code": "VAR_TOO_WORDY" },
61-
{ "code": "VAR_IS_TEMPORARY" }
58+
{ "code": "VAR_TOO_WORDY" }
6259
],
6360
"inheritParent": false,
6461
"parameters": {

system/core/util/Util.cfc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ Description :
2626
<cfargument name="in" type="array" required="true" hint="The array to convert"/>
2727
<cfscript>
2828
return arguments.in.reduce( function( result, item, index ){
29-
var target = result ?: structNew();
29+
var target = {};
30+
if( !isNull( result ) ){
31+
target = result;
32+
}
3033
target[ index ] = item;
3134
return target;
3235
} );

system/logging/LogBox.cfc

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
component accessors="true"{
1313

14-
14+
1515
/**
1616
* The LogBox unique ID
1717
*/
@@ -21,12 +21,12 @@ component accessors="true"{
2121
* The LogBox operating version
2222
*/
2323
property name="version";
24-
24+
2525
/**
2626
* The appender registration map
2727
*/
2828
property name="appenderRegistry" type="struct";
29-
29+
3030
/**
3131
* The Logger registration map
3232
*/
@@ -67,7 +67,7 @@ component accessors="true"{
6767
variables.categoryAppenders = "";
6868
// Version
6969
variables.version = "@build.version@+@build.number@";
70-
70+
7171
// Link incoming ColdBox argument
7272
variables.coldbox = arguments.coldbox;
7373

@@ -79,7 +79,7 @@ component accessors="true"{
7979

8080
/**
8181
* Configure logbox for operation. You can also re-configure LogBox programmatically. Basically we register all appenders here and all categories
82-
*
82+
*
8383
* @config The LogBoxConfig object to use to configure this instance of LogBox: coldbox.system.logging.config.LogBoxConfig
8484
* @config.doc_generic coldbox.system.logging.config.LogBoxConfig
8585
*/
@@ -109,7 +109,7 @@ component accessors="true"{
109109
levelMax = rootConfig.levelMax,
110110
appenders = getAppendersMap( rootConfig.appenders )
111111
};
112-
112+
113113
//Save in Registry
114114
variables.loggerRegistry = {
115115
"ROOT" = new coldbox.system.logging.Logger( argumentCollection=args )
@@ -119,7 +119,7 @@ component accessors="true"{
119119

120120
/**
121121
* Get the root logger object
122-
*
122+
*
123123
* @return coldbox.system.logging.Logger
124124
*/
125125
function getRootLogger(){
@@ -128,16 +128,16 @@ component accessors="true"{
128128

129129
/**
130130
* Get a logger object configured with a category name and appenders. If not configured, then it reverts to the root logger defined for this instance of LogBox
131-
*
131+
*
132132
* @category The category name to use in this logger or pass in the target object will log from and we will inspect the object and use its metadata name
133-
*
133+
*
134134
* @return coldbox.system.logging.Logger
135135
*/
136136
function getLogger( required category ){
137137
var root = getRootLogger();
138138

139139
// is category object?
140-
if( isObject( arguments.category ) ){
140+
if( isObject( arguments.category ) ){
141141
arguments.category = getMetadata( arguments.category ).name;
142142
}
143143

@@ -202,7 +202,7 @@ component accessors="true"{
202202

203203
/**
204204
* Register a new appender object in the appender registry.
205-
*
205+
*
206206
* @name A unique name for the appender to register. Only unique names can be registered per variables.
207207
* @class The appender's class to register. We will create, init it and register it for you.
208208
* @properties The structure of properties to configure this appender with.
@@ -222,9 +222,9 @@ component accessors="true"{
222222
if( !structKeyExists( variables.appenderRegistry, arguments.name ) ){
223223

224224
lock name="#variables.logboxID#.registerappender.#name#" type="exclusive" timeout="15" throwOnTimeout="true"{
225-
225+
226226
if( !structKeyExists( variables.appenderRegistry, arguments.name ) ){
227-
227+
228228
// Create appender and linking
229229
var oAppender = new "#arguments.class#"( argumentCollection=arguments );
230230
oAppender.setColdBox( variables.coldbox );
@@ -247,7 +247,7 @@ component accessors="true"{
247247

248248
/**
249249
* Get a parent logger according to category convention inheritance. If not found, it returns the root logger.
250-
*
250+
*
251251
* @category The category name to investigate for parents
252252
*/
253253
private function locateCategoryParentLogger( required category ){
@@ -278,20 +278,24 @@ component accessors="true"{
278278

279279
/**
280280
* Get a map of appenders by list. Usually called to get a category of appenders
281-
*
281+
*
282282
* @appenders The list of appenders to get
283283
*/
284284
struct function getAppendersMap( required appenders ){
285285
var results = arguments.appenders
286286
.listToArray()
287287
.reduce( function( result, item, index ){
288-
var target = result ?: structNew();
288+
var target = {};
289+
if( !isNull( arguments.result ) ){
290+
target = result;
291+
}
289292
target[ item ] = variables.appenderRegistry[ item ];
290293
return target;
291294
} );
292-
return results ?: structnew();
295+
296+
return ( isNull( results ) ? structNew() : results );
293297
}
294-
298+
295299
/**
296300
* Get Utility Object
297301
*/

system/modules/HTMLHelper/models/HTMLHelper.cfc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,10 @@ component extends="coldbox.system.FrameworkSupertype" accessors=true singleton{
23482348
var key = "";
23492349

23502350
// Metadata
2351-
var firstMetadata = getMetadata( arguments.data[ 1 ] ?: structNew() );
2351+
var firstMetadata = {};
2352+
if( !isNull( arguments.data[ 1 ] ) ){
2353+
firstMetadata = getMetadata( arguments.data[ 1 ] );
2354+
}
23522355
// All properties
23532356
var properties = structKeyExists( firstMetadata, "properties" ) ? firstMetadata.properties : [];
23542357
// Filtered properties
@@ -2398,7 +2401,9 @@ component extends="coldbox.system.FrameworkSupertype" accessors=true singleton{
23982401
required buffer
23992402
){
24002403
// Guess columns from first struct found
2401-
var columns = structKeyArray( data[ 1 ] ?: structNew() )
2404+
var thisData = ( isNull( data[ 1 ] ) ? structNew() : data[ 1 ] );
2405+
2406+
var columns = structKeyArray( thisData )
24022407
.filter( function( item ){
24032408
return ( passIncludeExclude( item, includes, excludes ) );
24042409
} );

system/web/context/RequestContext.cfc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -666,17 +666,17 @@ component serializable=false accessors="true"{
666666
* Are we in SSL or not? This method looks at cgi.server_port_secure for indication
667667
*/
668668
boolean function isSSL(){
669-
if( isBoolean( cgi.server_port_secure ) AND cgi.server_port_secure ){
670-
return true;
669+
if( isBoolean( cgi.server_port_secure ) AND cgi.server_port_secure ){
670+
return true;
671671
}
672672
// Add typical proxy headers for SSL
673-
if( getHTTPHeader( "x-forwarded-proto", "http" ) eq "https" ){
674-
return true;
673+
if( getHTTPHeader( "x-forwarded-proto", "http" ) eq "https" ){
674+
return true;
675675
}
676-
if( getHTTPHeader( "x-scheme", "http" ) eq "https" ){
677-
return true;
676+
if( getHTTPHeader( "x-scheme", "http" ) eq "https" ){
677+
return true;
678678
}
679-
// cgi.https
679+
// cgi.https
680680
if( cgi.keyExists( "https" ) and cgi.https eq "on" ){
681681
return true;
682682
}
@@ -1009,8 +1009,11 @@ component serializable=false accessors="true"{
10091009
if( arrayLen( foundRoute ) ){
10101010
var args = {
10111011
to = entryPoint & foundRoute[ 1 ].pattern,
1012-
ssl = arguments.ssl ?: javaCast( "null", "" )
1012+
ssl = javaCast( "null", "" )
10131013
};
1014+
if( !isNull( arguments.ssl ) ){
1015+
args.ssl = arguments.ssl;
1016+
}
10141017

10151018
// Process Params
10161019
arguments.params.each( function( key, value ){
@@ -1446,7 +1449,7 @@ component serializable=false accessors="true"{
14461449

14471450
/**
14481451
* Set an HTTP Response Header
1449-
*
1452+
*
14501453
* @statusCode the status code
14511454
* @statusText the status text
14521455
* @name The header name
@@ -1471,10 +1474,10 @@ component serializable=false accessors="true"{
14711474
getPageContext().getResponse().addHeader( javaCast( "string", arguments.name ), javaCast( "string", arguments.value ) );
14721475
variables.responseHeaders[ arguments.name ] = arguments.value;
14731476
} else {
1474-
throw(
1477+
throw(
14751478
message = "Invalid header arguments",
14761479
detail = "Pass in either a statusCode or name argument",
1477-
type = "RequestContext.InvalidHTTPHeaderParameters"
1480+
type = "RequestContext.InvalidHTTPHeaderParameters"
14781481
);
14791482
}
14801483

system/web/routing/Router.cfc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ component accessors="true" extends="coldbox.system.FrameworkSupertype" threadsaf
10691069
args = {
10701070
pattern = arguments.pattern,
10711071
event = arguments.target,
1072-
verbs = variables.thisRoute.verbs ?: "",
1072+
verbs = ( variables.thisRoute.keyExists( "verbs" ) ? variables.thisRoute.verbs : "" ),
10731073
name = arguments.name
10741074
};
10751075
}
@@ -1078,8 +1078,8 @@ component accessors="true" extends="coldbox.system.FrameworkSupertype" threadsaf
10781078
args = {
10791079
pattern = arguments.pattern,
10801080
response = arguments.target,
1081-
verbs = variables.thisRoute.verbs ?: "",
1082-
name = arguments.name
1081+
verbs = ( variables.thisRoute.keyExists( "verbs" ) ? variables.thisRoute.verbs : "" ),
1082+
name = arguments.name
10831083
};
10841084
}
10851085

system/web/services/RoutingService.cfc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,15 @@ component extends="coldbox.system.web.services.BaseService" accessors="true"{
244244
// Process Redirects
245245
if( routeResults.route.redirect.len() ){
246246
if( routeResults.route.redirect.findNoCase( "http" ) ){
247-
controller.relocate( URL=routeResults.route.redirect, statusCode=routeResults.route.statusCode ?: 301 );
247+
controller.relocate(
248+
URL = routeResults.route.redirect,
249+
statusCode = ( routeResults.route.keyExists( "statusCode" ) ? routeResults.route.statusCode : 301 )
250+
);
248251
} else {
249-
controller.relocate( event=routeResults.route.redirect, statusCode=routeResults.route.statusCode ?: 301 );
252+
controller.relocate(
253+
event = routeResults.route.redirect,
254+
statusCode = ( routeResults.route.keyExists( "statusCode" ) ? routeResults.route.statusCode : 301 )
255+
);
250256
}
251257
return;
252258
}

0 commit comments

Comments
 (0)