Description
openedon Jan 24, 2019
There are many places throughout the codebase (mostly in the main classes) where we modify data via assignment in some object (e.g., a Suite
) directly from some other class. this includes properties which are ostensibly "private" (e.g. Suite#_onlyTests
).
This breaks encapsulation/information-hiding. Refactor these instances by creating methods within the classes having these properties, and call those methods from whatever code is currently doing direct assignment.
Example:
mocha/lib/interfaces/common.js
Lines 169 to 180 in b5d8513
Instead, Suite
could expose an instance method (e.g., appendOnlyTest
) which appends the test to its _onlyTests
array. The consuming code would call test.parent.appendOnlyTest(test)
. Going a step further, the Test
class could expose an instance method (e.g. markOnly()
) which would make the call.
These changes can be incremental; we don't have to do it all at once. Any new methods will need unit tests.