Skip to content

Commit eb760b6

Browse files
committed
refactor: clean out variables that are being assigned to but not being read
Clears out private properties and local variables that are declared and assigned values, but aren't actually being read at any point. This will start being caught by tslint once we update to TS 2.6.
1 parent 6d94aec commit eb760b6

File tree

24 files changed

+20
-154
lines changed

24 files changed

+20
-154
lines changed

src/cdk/a11y/focus-trap/focus-trap.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ describe('FocusTrap', () => {
7676

7777
describe('with bindings', () => {
7878
let fixture: ComponentFixture<FocusTrapWithBindings>;
79-
let focusTrapInstance: FocusTrap;
8079

8180
beforeEach(() => {
8281
fixture = TestBed.createComponent(FocusTrapWithBindings);
8382
fixture.detectChanges();
84-
focusTrapInstance = fixture.componentInstance.focusTrapDirective.focusTrap;
8583
});
8684

8785
it('should clean up its anchor sibling elements on destroy', () => {

src/cdk/layout/media-matcher.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {LayoutModule, BreakpointObserver} from './index';
8+
import {LayoutModule} from './index';
99
import {MediaMatcher} from './media-matcher';
1010
import {async, TestBed, inject} from '@angular/core/testing';
1111
import {Platform} from '@angular/cdk/platform';
1212

1313
describe('MediaMatcher', () => {
14-
let breakpointManager: BreakpointObserver;
1514
let mediaMatcher: MediaMatcher;
1615

1716
beforeEach(async(() => {
@@ -20,12 +19,9 @@ describe('MediaMatcher', () => {
2019
});
2120
}));
2221

23-
beforeEach(inject(
24-
[BreakpointObserver, MediaMatcher],
25-
(bm: BreakpointObserver, mm: MediaMatcher) => {
26-
breakpointManager = bm;
27-
mediaMatcher = mm;
28-
}));
22+
beforeEach(inject([MediaMatcher], (mm: MediaMatcher) => {
23+
mediaMatcher = mm;
24+
}));
2925

3026
it('correctly returns a MediaQueryList to check for matches', () => {
3127
expect(mediaMatcher.matchMedia('(min-width: 1px)').matches).toBeTruthy();

src/cdk/overlay/position/connected-position-strategy.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ import {OverlayRef} from '../overlay-ref';
3535
* of the overlay.
3636
*/
3737
export class ConnectedPositionStrategy implements PositionStrategy {
38-
/** The overlay to which this strategy is attached. */
39-
private _overlayRef: OverlayRef;
40-
4138
/** Layout direction of the position strategy. */
4239
private _dir = 'ltr';
4340

@@ -100,7 +97,6 @@ export class ConnectedPositionStrategy implements PositionStrategy {
10097

10198
/** Attach this position strategy to an overlay. */
10299
attach(overlayRef: OverlayRef): void {
103-
this._overlayRef = overlayRef;
104100
this._pane = overlayRef.overlayElement;
105101
this._resizeSubscription.unsubscribe();
106102
this._resizeSubscription = this._viewportRuler.change().subscribe(() => this.apply());

src/cdk/tree/tree.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
139139
/** Subject that emits when the component has been destroyed. */
140140
private _onDestroy = new Subject<void>();
141141

142-
/** Latest data provided by the data source through the connect interface. */
143-
private _data = new Array<T>();
144-
145142
/** Differ used to find the changes in the data provided by the data source. */
146143
private _dataDiffer: IterableDiffer<T>;
147144

@@ -231,8 +228,6 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
231228
* clearing the node outlet. Otherwise start listening for new data.
232229
*/
233230
private _switchDataSource(dataSource: DataSource<T> | Observable<T[]> | T[]) {
234-
this._data = new Array<T>();
235-
236231
if (this._dataSource && typeof (this._dataSource as DataSource<T>).disconnect === 'function') {
237232
(this.dataSource as DataSource<T>).disconnect(this);
238233
}
@@ -269,10 +264,7 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
269264

270265
if (dataStream) {
271266
this._dataSubscription = dataStream.pipe(takeUntil(this._onDestroy))
272-
.subscribe(data => {
273-
this._data = data;
274-
this._renderNodeChanges(data);
275-
});
267+
.subscribe(data => this._renderNodeChanges(data));
276268
} else {
277269
throw getTreeNoValidDataSourceError();
278270
}

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ describe('MatAutocomplete', () => {
14681468
zone.simulateZoneExit();
14691469

14701470
expect(spy).toHaveBeenCalledWith(jasmine.any(MatOptionSelectionChange));
1471+
subscription!.unsubscribe();
14711472
}));
14721473

14731474
});

src/lib/button-toggle/button-toggle.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ describe('MatButtonToggle with forms', () => {
8181
describe('button toggle group with ngModel and change event', () => {
8282
let fixture: ComponentFixture<ButtonToggleGroupWithNgModel>;
8383
let groupDebugElement: DebugElement;
84-
let groupNativeElement: HTMLElement;
8584
let buttonToggleDebugElements: DebugElement[];
86-
let buttonToggleNativeElements: HTMLElement[];
8785
let groupInstance: MatButtonToggleGroup;
8886
let buttonToggleInstances: MatButtonToggle[];
8987
let testComponent: ButtonToggleGroupWithNgModel;
@@ -96,13 +94,10 @@ describe('MatButtonToggle with forms', () => {
9694
testComponent = fixture.debugElement.componentInstance;
9795

9896
groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup));
99-
groupNativeElement = groupDebugElement.nativeElement;
10097
groupInstance = groupDebugElement.injector.get<MatButtonToggleGroup>(MatButtonToggleGroup);
10198
groupNgModel = groupDebugElement.injector.get<NgModel>(NgModel);
10299

103100
buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle));
104-
buttonToggleNativeElements =
105-
buttonToggleDebugElements.map(debugEl => debugEl.nativeElement);
106101
buttonToggleInstances = buttonToggleDebugElements.map(debugEl => debugEl.componentInstance);
107102
buttonToggleLabels = buttonToggleDebugElements.map(
108103
debugEl => debugEl.query(By.css('label')).nativeElement);
@@ -545,14 +540,11 @@ describe('MatButtonToggle without forms', () => {
545540
let buttonToggleNativeElement: HTMLElement;
546541
let buttonToggleLabelElement: HTMLLabelElement;
547542
let buttonToggleInstance: MatButtonToggle;
548-
let testComponent: StandaloneButtonToggle;
549543

550544
beforeEach(async(() => {
551545
fixture = TestBed.createComponent(StandaloneButtonToggle);
552546
fixture.detectChanges();
553547

554-
testComponent = fixture.debugElement.componentInstance;
555-
556548
buttonToggleDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle));
557549
buttonToggleNativeElement = buttonToggleDebugElement.nativeElement;
558550
buttonToggleLabelElement = fixture.debugElement.query(By.css('label')).nativeElement;

src/lib/checkbox/checkbox.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ describe('MatCheckbox', () => {
748748
let checkboxNativeElement: HTMLElement;
749749
let testComponent: CheckboxWithTabIndex;
750750
let inputElement: HTMLInputElement;
751-
let labelElement: HTMLLabelElement;
752751

753752
beforeEach(() => {
754753
fixture = TestBed.createComponent(CheckboxWithTabIndex);
@@ -758,7 +757,6 @@ describe('MatCheckbox', () => {
758757
checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox));
759758
checkboxNativeElement = checkboxDebugElement.nativeElement;
760759
inputElement = <HTMLInputElement>checkboxNativeElement.querySelector('input');
761-
labelElement = <HTMLLabelElement>checkboxNativeElement.querySelector('label');
762760
});
763761

764762
it('should preserve any given tabIndex', () => {
@@ -940,7 +938,6 @@ describe('MatCheckbox', () => {
940938

941939
describe('without label', () => {
942940
let testComponent: CheckboxWithoutLabel;
943-
let checkboxElement: HTMLElement;
944941
let checkboxInnerContainer: HTMLElement;
945942

946943
beforeEach(() => {
@@ -949,7 +946,6 @@ describe('MatCheckbox', () => {
949946
const checkboxDebugEl = fixture.debugElement.query(By.directive(MatCheckbox));
950947

951948
testComponent = fixture.componentInstance;
952-
checkboxElement = checkboxDebugEl.nativeElement;
953949
checkboxInnerContainer = checkboxDebugEl
954950
.query(By.css('.mat-checkbox-inner-container')).nativeElement;
955951
});

src/lib/chips/chip-list.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,13 @@ describe('MatChipList', () => {
455455
});
456456

457457
describe('forms integration', () => {
458-
let formField: HTMLElement;
459458
let nativeChips: HTMLElement[];
460459

461460
describe('single selection', () => {
462461
beforeEach(() => {
463462
fixture = TestBed.createComponent(BasicChipList);
464463
fixture.detectChanges();
465464

466-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
467465
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
468466
.map((chip) => chip.nativeElement);
469467
chips = fixture.componentInstance.chips;
@@ -627,7 +625,6 @@ describe('MatChipList', () => {
627625
fixture = TestBed.createComponent(MultiSelectionChipList);
628626
fixture.detectChanges();
629627

630-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
631628
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
632629
.map((chip) => chip.nativeElement);
633630
chips = fixture.componentInstance.chips;
@@ -705,14 +702,12 @@ describe('MatChipList', () => {
705702
});
706703

707704
describe('chip list with chip input', () => {
708-
let formField: HTMLElement;
709705
let nativeChips: HTMLElement[];
710706

711707
beforeEach(() => {
712708
fixture = TestBed.createComponent(InputChipList);
713709
fixture.detectChanges();
714710

715-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
716711
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
717712
.map((chip) => chip.nativeElement);
718713
});

src/lib/chips/chip-list.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
389389
if (this._changeSubscription) {
390390
this._changeSubscription.unsubscribe();
391391
}
392+
393+
if (this._chipRemoveSubscription) {
394+
this._chipRemoveSubscription.unsubscribe();
395+
}
396+
392397
this._dropSubscriptions();
393398
this.stateChanges.complete();
394399
}

src/lib/chips/chip.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import {createKeyboardEvent} from '@angular/cdk/testing';
44
import {Component, DebugElement} from '@angular/core';
55
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
66
import {By} from '@angular/platform-browser';
7-
import {MatChip, MatChipEvent, MatChipList, MatChipSelectionChange, MatChipsModule} from './index';
7+
import {MatChip, MatChipEvent, MatChipSelectionChange, MatChipsModule} from './index';
88

99

1010
describe('Chips', () => {
1111
let fixture: ComponentFixture<any>;
1212
let chipDebugElement: DebugElement;
13-
let chipListNativeElement: HTMLElement;
1413
let chipNativeElement: HTMLElement;
1514
let chipInstance: MatChip;
1615

@@ -59,7 +58,6 @@ describe('Chips', () => {
5958
fixture.detectChanges();
6059

6160
chipDebugElement = fixture.debugElement.query(By.directive(MatChip));
62-
chipListNativeElement = fixture.debugElement.query(By.directive(MatChipList)).nativeElement;
6361
chipNativeElement = chipDebugElement.nativeElement;
6462
chipInstance = chipDebugElement.injector.get(MatChip);
6563
testComponent = fixture.debugElement.componentInstance;

src/lib/core/ripple/ripple.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,12 @@ describe('MatRipple', () => {
543543

544544
describe('configuring behavior', () => {
545545
let controller: RippleContainerWithInputBindings;
546-
let rippleComponent: MatRipple;
547546

548547
beforeEach(() => {
549548
fixture = TestBed.createComponent(RippleContainerWithInputBindings);
550549
fixture.detectChanges();
551550

552551
controller = fixture.debugElement.componentInstance;
553-
rippleComponent = controller.ripple;
554552
rippleTarget = fixture.debugElement.nativeElement.querySelector('[mat-ripple]');
555553
});
556554

src/lib/datepicker/month-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ describe('MatMonthView', () => {
262262

263263
describe('month view with date filter', () => {
264264
let fixture: ComponentFixture<MonthViewWithDateFilter>;
265-
let testComponent: MonthViewWithDateFilter;
266265
let monthViewNativeElement: Element;
267266

268267
beforeEach(() => {
@@ -271,7 +270,6 @@ describe('MatMonthView', () => {
271270

272271
let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView));
273272
monthViewNativeElement = monthViewDebugElement.nativeElement;
274-
testComponent = fixture.componentInstance;
275273
});
276274

277275
it('should disable filtered dates', () => {

src/lib/datepicker/multi-year-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ describe('MatMultiYearView', () => {
225225

226226
describe('multi year view with date filter', () => {
227227
let fixture: ComponentFixture<MultiYearViewWithDateFilter>;
228-
let testComponent: MultiYearViewWithDateFilter;
229228
let multiYearViewNativeElement: Element;
230229

231230
beforeEach(() => {
@@ -234,7 +233,6 @@ describe('MatMultiYearView', () => {
234233

235234
const multiYearViewDebugElement = fixture.debugElement.query(By.directive(MatMultiYearView));
236235
multiYearViewNativeElement = multiYearViewDebugElement.nativeElement;
237-
testComponent = fixture.componentInstance;
238236
});
239237

240238
it('should disablex years with no enabled days', () => {

src/lib/datepicker/year-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ describe('MatYearView', () => {
293293

294294
describe('year view with date filter', () => {
295295
let fixture: ComponentFixture<YearViewWithDateFilter>;
296-
let testComponent: YearViewWithDateFilter;
297296
let yearViewNativeElement: Element;
298297

299298
beforeEach(() => {
@@ -302,7 +301,6 @@ describe('MatYearView', () => {
302301

303302
const yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView));
304303
yearViewNativeElement = yearViewDebugElement.nativeElement;
305-
testComponent = fixture.componentInstance;
306304
});
307305

308306
it('should disable months with no enabled days', () => {

src/lib/list/list.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export class MatListSubheaderCssMatStyler {}
109109
})
110110
export class MatListItem extends _MatListItemMixinBase implements AfterContentInit,
111111
CanDisableRipple {
112-
private _lineSetter: MatLineSetter;
113112
private _isNavList: boolean = false;
114113

115114
@ContentChildren(MatLine) _lines: QueryList<MatLine>;
@@ -130,7 +129,9 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn
130129
}
131130

132131
ngAfterContentInit() {
133-
this._lineSetter = new MatLineSetter(this._lines, this._element);
132+
// TODO: consider turning the setter into a function, it doesn't do anything as a class.
133+
// tslint:disable-next-line:no-unused-expression
134+
new MatLineSetter(this._lines, this._element);
134135
}
135136

136137
/** Whether this list item should show a ripple effect when clicked. */

0 commit comments

Comments
 (0)