[SERVER-23728] Enable the no-unused-expressions ESLint rule to find dead code Created: 14/Apr/16  Updated: 06/Dec/17  Resolved: 11/Apr/17

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.5.6

Type: Task Priority: Major - P3
Reporter: Kamran K. Assignee: Eddie Louie
Resolution: Done Votes: 1
Labels: bkp, tig-eslint
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-28550 Add no-unused-vars ESLint rule to fin... Closed
is related to SERVER-23704 shard_keycount.js does not invoke ano... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v3.2
Sprint: TIG 2017-04-17
Participants:
Linked BF Score: 0

 Description   

The no-unused-expressions rule can catch bugs like SERVER-23704.

/Users/kk/code/mongo/mongo/jstests/auth/basic_role_auth.js
  191:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/covered_index_sort_3.js
  11:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/distinct_speed1.js
  12:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/elemMatchProjection.js
  100:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/group1.js
  103:9  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  118:9  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/js4.js
  19:9  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  40:9  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/core/ora.js
  20:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
  65:9  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/replsets/pipelineout.js
  21:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  26:5  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  30:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/sharding/hash_basic.js
  17:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
/Users/kk/code/mongo/mongo/jstests/sharding/shard_keycount.js
  2:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
 
✖ 15 problems (15 errors, 0 warnings)



 Comments   
Comment by Eddie Louie [ 11/Apr/17 ]

The deadlock uncovered in jstests/core/eval_wait_for_read_write_concern.js will be tracked with SERVER-28746. Closing this ticket as the ESLint changes are complete.

Comment by Max Hirschhorn [ 07/Apr/17 ]

Also disabled the jstests/core/eval_wait_for_read_write_concern.js test as it hangs.

eddie.louie, this ticket cannot be resolved with the jstests/core/eval_wait_for_read_write_concern.js test commented out. The purpose of this ticket was not only to enable the no-unused-expressions lint rule, but also to ensure that any affected test cases get enabled. We should determine why the test is hanging. For example, I wonder if it shouldn't be running as part of the jstests/core/ directory and that's causing a problem. If so, then it could be moved to the jstests/replsets/ directory and modified to start its own ReplSetTest.

Comment by Eddie Louie [ 06/Apr/17 ]

Fixed two new lint errors as part of this ticket.
Also disabled the jstests/core/eval_wait_for_read_write_concern.js test as it hangs.

Comment by Githook User [ 06/Apr/17 ]

Author:

{u'username': u'elouie99', u'name': u'Eddie Louie', u'email': u'eddie.louie@mongodb.com'}

Message: SERVER-23728 Disable test
Branch: master
https://github.com/mongodb/mongo/commit/155716fc56c840fb5608ddb9ba39c1143b69f6ba

Comment by Githook User [ 06/Apr/17 ]

Author:

{u'username': u'elouie99', u'name': u'Eddie Louie', u'email': u'eddie.louie@mongodb.com'}

Message: SERVER-23728 Fix lint failures
Branch: master
https://github.com/mongodb/mongo/commit/4516cbf1786f35557fe2f2e26e2e25373aa7af83

Comment by Githook User [ 05/Apr/17 ]

Author:

{u'username': u'elouie99', u'name': u'Eddie Louie', u'email': u'eddie.louie@mongodb.com'}

Message: SERVER-23728 Enable the no-unused-expressions ESLint rule
Branch: master
https://github.com/mongodb/mongo/commit/2569b254a53586f1177b82bdc567463e84be75e2

Generated at Thu Feb 08 04:04:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.