Skip to content

refactor: clean out variables that are being assigned to but not being read #9871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/cdk/a11y/focus-trap/focus-trap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ describe('FocusTrap', () => {

describe('with bindings', () => {
let fixture: ComponentFixture<FocusTrapWithBindings>;
let focusTrapInstance: FocusTrap;

beforeEach(() => {
fixture = TestBed.createComponent(FocusTrapWithBindings);
fixture.detectChanges();
focusTrapInstance = fixture.componentInstance.focusTrapDirective.focusTrap;
});

it('should clean up its anchor sibling elements on destroy', () => {
Expand Down
12 changes: 4 additions & 8 deletions src/cdk/layout/media-matcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {LayoutModule, BreakpointObserver} from './index';
import {LayoutModule} from './index';
import {MediaMatcher} from './media-matcher';
import {async, TestBed, inject} from '@angular/core/testing';
import {Platform} from '@angular/cdk/platform';

describe('MediaMatcher', () => {
let breakpointManager: BreakpointObserver;
let mediaMatcher: MediaMatcher;

beforeEach(async(() => {
Expand All @@ -20,12 +19,9 @@ describe('MediaMatcher', () => {
});
}));

beforeEach(inject(
[BreakpointObserver, MediaMatcher],
(bm: BreakpointObserver, mm: MediaMatcher) => {
breakpointManager = bm;
mediaMatcher = mm;
}));
beforeEach(inject([MediaMatcher], (mm: MediaMatcher) => {
mediaMatcher = mm;
}));

it('correctly returns a MediaQueryList to check for matches', () => {
expect(mediaMatcher.matchMedia('(min-width: 1px)').matches).toBeTruthy();
Expand Down
4 changes: 0 additions & 4 deletions src/cdk/overlay/position/connected-position-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import {OverlayRef} from '../overlay-ref';
* of the overlay.
*/
export class ConnectedPositionStrategy implements PositionStrategy {
/** The overlay to which this strategy is attached. */
private _overlayRef: OverlayRef;

/** Layout direction of the position strategy. */
private _dir = 'ltr';

Expand Down Expand Up @@ -100,7 +97,6 @@ export class ConnectedPositionStrategy implements PositionStrategy {

/** Attach this position strategy to an overlay. */
attach(overlayRef: OverlayRef): void {
this._overlayRef = overlayRef;
this._pane = overlayRef.overlayElement;
this._resizeSubscription.unsubscribe();
this._resizeSubscription = this._viewportRuler.change().subscribe(() => this.apply());
Expand Down
10 changes: 1 addition & 9 deletions src/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
/** Subject that emits when the component has been destroyed. */
private _onDestroy = new Subject<void>();

/** Latest data provided by the data source through the connect interface. */
private _data = new Array<T>();

/** Differ used to find the changes in the data provided by the data source. */
private _dataDiffer: IterableDiffer<T>;

Expand Down Expand Up @@ -231,8 +228,6 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {
* clearing the node outlet. Otherwise start listening for new data.
*/
private _switchDataSource(dataSource: DataSource<T> | Observable<T[]> | T[]) {
this._data = new Array<T>();

if (this._dataSource && typeof (this._dataSource as DataSource<T>).disconnect === 'function') {
(this.dataSource as DataSource<T>).disconnect(this);
}
Expand Down Expand Up @@ -269,10 +264,7 @@ export class CdkTree<T> implements CollectionViewer, OnInit, OnDestroy {

if (dataStream) {
this._dataSubscription = dataStream.pipe(takeUntil(this._onDestroy))
.subscribe(data => {
this._data = data;
this._renderNodeChanges(data);
});
.subscribe(data => this._renderNodeChanges(data));
} else {
throw getTreeNoValidDataSourceError();
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ describe('MatAutocomplete', () => {
zone.simulateZoneExit();

expect(spy).toHaveBeenCalledWith(jasmine.any(MatOptionSelectionChange));
subscription!.unsubscribe();
}));

});
Expand Down
8 changes: 0 additions & 8 deletions src/lib/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ describe('MatButtonToggle with forms', () => {
describe('button toggle group with ngModel and change event', () => {
let fixture: ComponentFixture<ButtonToggleGroupWithNgModel>;
let groupDebugElement: DebugElement;
let groupNativeElement: HTMLElement;
let buttonToggleDebugElements: DebugElement[];
let buttonToggleNativeElements: HTMLElement[];
let groupInstance: MatButtonToggleGroup;
let buttonToggleInstances: MatButtonToggle[];
let testComponent: ButtonToggleGroupWithNgModel;
Expand All @@ -96,13 +94,10 @@ describe('MatButtonToggle with forms', () => {
testComponent = fixture.debugElement.componentInstance;

groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup));
groupNativeElement = groupDebugElement.nativeElement;
groupInstance = groupDebugElement.injector.get<MatButtonToggleGroup>(MatButtonToggleGroup);
groupNgModel = groupDebugElement.injector.get<NgModel>(NgModel);

buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle));
buttonToggleNativeElements =
buttonToggleDebugElements.map(debugEl => debugEl.nativeElement);
buttonToggleInstances = buttonToggleDebugElements.map(debugEl => debugEl.componentInstance);
buttonToggleLabels = buttonToggleDebugElements.map(
debugEl => debugEl.query(By.css('label')).nativeElement);
Expand Down Expand Up @@ -545,14 +540,11 @@ describe('MatButtonToggle without forms', () => {
let buttonToggleNativeElement: HTMLElement;
let buttonToggleLabelElement: HTMLLabelElement;
let buttonToggleInstance: MatButtonToggle;
let testComponent: StandaloneButtonToggle;

beforeEach(async(() => {
fixture = TestBed.createComponent(StandaloneButtonToggle);
fixture.detectChanges();

testComponent = fixture.debugElement.componentInstance;

buttonToggleDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle));
buttonToggleNativeElement = buttonToggleDebugElement.nativeElement;
buttonToggleLabelElement = fixture.debugElement.query(By.css('label')).nativeElement;
Expand Down
4 changes: 0 additions & 4 deletions src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ describe('MatCheckbox', () => {
let checkboxNativeElement: HTMLElement;
let testComponent: CheckboxWithTabIndex;
let inputElement: HTMLInputElement;
let labelElement: HTMLLabelElement;

beforeEach(() => {
fixture = TestBed.createComponent(CheckboxWithTabIndex);
Expand All @@ -758,7 +757,6 @@ describe('MatCheckbox', () => {
checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox));
checkboxNativeElement = checkboxDebugElement.nativeElement;
inputElement = <HTMLInputElement>checkboxNativeElement.querySelector('input');
labelElement = <HTMLLabelElement>checkboxNativeElement.querySelector('label');
});

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

describe('without label', () => {
let testComponent: CheckboxWithoutLabel;
let checkboxElement: HTMLElement;
let checkboxInnerContainer: HTMLElement;

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

testComponent = fixture.componentInstance;
checkboxElement = checkboxDebugEl.nativeElement;
checkboxInnerContainer = checkboxDebugEl
.query(By.css('.mat-checkbox-inner-container')).nativeElement;
});
Expand Down
5 changes: 0 additions & 5 deletions src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,13 @@ describe('MatChipList', () => {
});

describe('forms integration', () => {
let formField: HTMLElement;
let nativeChips: HTMLElement[];

describe('single selection', () => {
beforeEach(() => {
fixture = TestBed.createComponent(BasicChipList);
fixture.detectChanges();

formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
.map((chip) => chip.nativeElement);
chips = fixture.componentInstance.chips;
Expand Down Expand Up @@ -627,7 +625,6 @@ describe('MatChipList', () => {
fixture = TestBed.createComponent(MultiSelectionChipList);
fixture.detectChanges();

formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
.map((chip) => chip.nativeElement);
chips = fixture.componentInstance.chips;
Expand Down Expand Up @@ -705,14 +702,12 @@ describe('MatChipList', () => {
});

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

beforeEach(() => {
fixture = TestBed.createComponent(InputChipList);
fixture.detectChanges();

formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
.map((chip) => chip.nativeElement);
});
Expand Down
5 changes: 5 additions & 0 deletions src/lib/chips/chip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
if (this._changeSubscription) {
this._changeSubscription.unsubscribe();
}

if (this._chipRemoveSubscription) {
this._chipRemoveSubscription.unsubscribe();
}

this._dropSubscriptions();
this.stateChanges.complete();
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/chips/chip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import {createKeyboardEvent} from '@angular/cdk/testing';
import {Component, DebugElement} from '@angular/core';
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {MatChip, MatChipEvent, MatChipList, MatChipSelectionChange, MatChipsModule} from './index';
import {MatChip, MatChipEvent, MatChipSelectionChange, MatChipsModule} from './index';


describe('Chips', () => {
let fixture: ComponentFixture<any>;
let chipDebugElement: DebugElement;
let chipListNativeElement: HTMLElement;
let chipNativeElement: HTMLElement;
let chipInstance: MatChip;

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

chipDebugElement = fixture.debugElement.query(By.directive(MatChip));
chipListNativeElement = fixture.debugElement.query(By.directive(MatChipList)).nativeElement;
chipNativeElement = chipDebugElement.nativeElement;
chipInstance = chipDebugElement.injector.get(MatChip);
testComponent = fixture.debugElement.componentInstance;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/core/ripple/ripple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,12 @@ describe('MatRipple', () => {

describe('configuring behavior', () => {
let controller: RippleContainerWithInputBindings;
let rippleComponent: MatRipple;

beforeEach(() => {
fixture = TestBed.createComponent(RippleContainerWithInputBindings);
fixture.detectChanges();

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

Expand Down
2 changes: 0 additions & 2 deletions src/lib/datepicker/month-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ describe('MatMonthView', () => {

describe('month view with date filter', () => {
let fixture: ComponentFixture<MonthViewWithDateFilter>;
let testComponent: MonthViewWithDateFilter;
let monthViewNativeElement: Element;

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

let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView));
monthViewNativeElement = monthViewDebugElement.nativeElement;
testComponent = fixture.componentInstance;
});

it('should disable filtered dates', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/datepicker/multi-year-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ describe('MatMultiYearView', () => {

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

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

const multiYearViewDebugElement = fixture.debugElement.query(By.directive(MatMultiYearView));
multiYearViewNativeElement = multiYearViewDebugElement.nativeElement;
testComponent = fixture.componentInstance;
});

it('should disablex years with no enabled days', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/datepicker/year-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ describe('MatYearView', () => {

describe('year view with date filter', () => {
let fixture: ComponentFixture<YearViewWithDateFilter>;
let testComponent: YearViewWithDateFilter;
let yearViewNativeElement: Element;

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

const yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView));
yearViewNativeElement = yearViewDebugElement.nativeElement;
testComponent = fixture.componentInstance;
});

it('should disable months with no enabled days', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export class MatListSubheaderCssMatStyler {}
})
export class MatListItem extends _MatListItemMixinBase implements AfterContentInit,
CanDisableRipple {
private _lineSetter: MatLineSetter;
private _isNavList: boolean = false;

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

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

/** Whether this list item should show a ripple effect when clicked. */
Expand Down
Loading