Skip to content

Commit 7a9c54a

Browse files
committed
Methods that override must have "override" keyword
1 parent 5d1702f commit 7a9c54a

24 files changed

+43
-42
lines changed

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"noUnusedLocals": false, /* Report errors on unused locals. */
99
"forceConsistentCasingInFileNames": true,
1010
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
11+
"noImplicitOverride": true, /* Error to override a method without specifying the `override` keyword */
1112
"esModuleInterop": true,
1213
"allowJs": true
1314
},

whisker-main/src/whisker/integerlist/BiasedVariableLengthConstrainedChromosomeMutation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class BiasedVariableLengthConstrainedChromosomeMutation extends VariableL
2828
super(min, max, length, reservedCodons, gaussianMutationPower);
2929
}
3030

31-
protected _getMutationProbability(idx: number, numberOfCodons: number): number {
31+
protected override _getMutationProbability(idx: number, numberOfCodons: number): number {
3232
Preconditions.checkArgument(idx < numberOfCodons);
3333
return 2 * (idx + 1) / (numberOfCodons * (numberOfCodons + 1));
3434
}

whisker-main/src/whisker/model/components/Condition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class Condition extends Check {
5252
/**
5353
* Get a compact representation for this condition for edge tracing.
5454
*/
55-
toString() {
55+
override toString(): string {
5656
let result = (this._negated ? "!" : "") + this.name + "(";
5757

5858
if (this.args.length == 1) {

whisker-main/src/whisker/model/components/Effect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Effect extends Check {
6060
/**
6161
* Get a readable output for an failed effect trace.
6262
*/
63-
toString() {
63+
override toString(): string {
6464
let result = (this.negated ? "!" : "") + this.name + "(";
6565

6666
if (this.args.length == 1) {

whisker-main/src/whisker/model/components/ModelEdge.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class ProgramModelEdge extends ModelEdge {
201201
super(id, label, graphID, from, to, forceTestAfter, forceTestAt);
202202
}
203203

204-
reset(): void {
204+
override reset(): void {
205205
super.reset();
206206
this.failedEffects = [];
207207
}
@@ -217,14 +217,14 @@ export class ProgramModelEdge extends ModelEdge {
217217
/**
218218
* Register the check listener and test driver on the conditions and effects.
219219
*/
220-
registerComponents(cu: CheckUtility, testDriver: TestDriver, caseSensitive: boolean): void {
220+
override registerComponents(cu: CheckUtility, testDriver: TestDriver, caseSensitive: boolean): void {
221221
super.registerComponents(cu, testDriver, caseSensitive);
222222
this.effects.forEach(effect => {
223223
effect.registerComponents(testDriver, cu, caseSensitive, this.graphID);
224224
});
225225
}
226226

227-
simplifyForSave() {
227+
override simplifyForSave() {
228228
let effects = [];
229229
this.effects.forEach(effect => {
230230
effects.push(effect.simplifyForSave());
@@ -239,7 +239,7 @@ export class ProgramModelEdge extends ModelEdge {
239239
* Check the conditions and effects for checks that are depending on the check listeners and the fired events.
240240
* Effects are checked for Function:true Checks.
241241
*/
242-
checkConditionsOnEvent(t: TestDriver, cu: CheckUtility, stepsSinceLastTransition: number, stepsSinceEnd: number,
242+
override checkConditionsOnEvent(t: TestDriver, cu: CheckUtility, stepsSinceLastTransition: number, stepsSinceEnd: number,
243243
eventStrings: string[]): Condition[] {
244244
if (this.failedForcedTest) {
245245
return this.conditions;
@@ -335,14 +335,14 @@ export class UserModelEdge extends ModelEdge {
335335
/**
336336
* Register the check listener and test driver on the conditions and input effects.
337337
*/
338-
registerComponents(checkListener: CheckUtility, testDriver: TestDriver, caseSensitive: boolean): void {
338+
override registerComponents(checkListener: CheckUtility, testDriver: TestDriver, caseSensitive: boolean): void {
339339
super.registerComponents(checkListener, testDriver, caseSensitive);
340340
this.inputEffects.forEach(effect => {
341341
effect.registerComponents(testDriver, caseSensitive);
342342
});
343343
}
344344

345-
simplifyForSave() {
345+
override simplifyForSave() {
346346
let inputEffects = [];
347347
this.inputEffects.forEach(effect => {
348348
inputEffects.push(effect.simplifyForSave());

whisker-main/src/whisker/search/ListChromosome.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export abstract class ListChromosome<T> extends Chromosome {
5050
this._genes = genes;
5151
}
5252

53-
public toString = () : string => {
53+
public override toString = () : string => {
5454
let result = "";
5555
for(const gene of this.getGenes()) {
5656
result += gene + ":";
@@ -64,5 +64,5 @@ export abstract class ListChromosome<T> extends Chromosome {
6464
* TODO: This is a bit of a hack because of polymorphism. There must be a nicer way?
6565
* @param newGenes
6666
*/
67-
abstract cloneWith(newGenes: T[]);
67+
abstract override cloneWith(newGenes: T[]);
6868
}

whisker-main/src/whisker/search/algorithms/MIO.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class MIO<C extends Chromosome> extends SearchAlgorithmDefault<C> {
4343
/**
4444
* Defines SearchParameters set within the config file.
4545
*/
46-
protected _properties: MIOProperties<C>;
46+
protected override _properties: MIOProperties<C>;
4747

4848
/**
4949
* Function determining how good a chromosome performs with respect to a target statement.
@@ -317,7 +317,7 @@ open independent goals: ${this._uncoveredIndependentFitnessFunctions.size}`);
317317
*
318318
* @param chromosome The candidate chromosome for the archive.
319319
*/
320-
protected updateArchive(chromosome: C): void {
320+
protected override updateArchive(chromosome: C): void {
321321
this.updateCoveredArchive(chromosome);
322322
this.updateUncoveredArchive(chromosome);
323323
}

whisker-main/src/whisker/search/algorithms/MOSA.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class MOSA<C extends Chromosome> extends SearchAlgorithmDefault<C> {
4141
/**
4242
* Defines SearchParameters set within the config file.
4343
*/
44-
protected _properties: GeneticAlgorithmProperties<C>;
44+
protected override _properties: GeneticAlgorithmProperties<C>;
4545

4646
/**
4747
* Defines the selection operator used by this MOSA instance.
@@ -411,7 +411,7 @@ export class MOSA<C extends Chromosome> extends SearchAlgorithmDefault<C> {
411411
* - createdTestsToReachFullCoverage
412412
* - timeToReachFullCoverage
413413
*/
414-
protected updateStatistics(): void {
414+
protected override updateStatistics(): void {
415415
StatisticsCollector.getInstance().bestTestSuiteSize = this._bestIndividuals.length;
416416
if (this._archive.size == this._fitnessFunctions.size && !this._fullCoverageReached) {
417417
this._fullCoverageReached = true;

whisker-main/src/whisker/search/algorithms/NEAT.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class NEAT extends SearchAlgorithmDefault<NeatChromosome> {
7171
*
7272
* @param candidateChromosome The candidate chromosome to update the archive with.
7373
*/
74-
protected updateArchive(candidateChromosome: NeatChromosome): void {
74+
protected override updateArchive(candidateChromosome: NeatChromosome): void {
7575

7676
// We save the first chromosome which managed to cover a block instead of the best performing network since
7777
// otherwise the dynamic test suite later fails to cover the easiest blocks, e.g simple GameOver state.

whisker-main/src/whisker/search/algorithms/RandomSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class RandomSearch<C extends Chromosome> extends SearchAlgorithmDefault<C
9191
* - createdTestsToReachFullCoverage
9292
* - timeToReachFullCoverage
9393
*/
94-
protected updateStatistics(): void {
94+
protected override updateStatistics(): void {
9595
StatisticsCollector.getInstance().bestTestSuiteSize = this._bestIndividuals.length;
9696
StatisticsCollector.getInstance().incrementIterationCount();
9797
if (this._archive.size == this._fitnessFunctions.size && !this._fullCoverageReached) {

0 commit comments

Comments
 (0)