Skip to content

Commit

Permalink
refactor: clean up unused code and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Jul 24, 2020
1 parent 065520d commit 05588fc
Show file tree
Hide file tree
Showing 35 changed files with 34 additions and 90 deletions.
2 changes: 1 addition & 1 deletion lib/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as path from 'path';
import * as ts from 'typescript';

const distRoot = path.join(__dirname, '../dist');
const { versions: monorepoVersions, packages: monorepoPackages } = require('../.monorepo.json');
const { packages: monorepoPackages } = require('../.monorepo.json');


export interface PackageInfo {
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/analytics-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AnalyticsCommand extends Command<AnalyticsCommandSchema> {
return 1;
} else {
// No argument were passed.
await this.printHelp(options);
await this.printHelp();

return 2;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ export class AnalyticsCommand extends Command<AnalyticsCommandSchema> {
break;

default:
await this.printHelp(options);
await this.printHelp();

return 3;
}
Expand All @@ -81,7 +81,7 @@ export class AnalyticsCommand extends Command<AnalyticsCommandSchema> {
break;

default:
await this.printHelp(options);
await this.printHelp();

return 4;
}
Expand Down
7 changes: 0 additions & 7 deletions packages/angular/cli/commands/config-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ function _validateBoolean(value: string) {
throw new Error(`Invalid value type; expected Boolean, received ${JSON.stringify(value)}.`);
}
}
function _validateNumber(value: string) {
const numberValue = Number(value);
if (!Number.isFinite(numberValue)) {
return numberValue;
}
throw new Error(`Invalid value type; expected Number, received ${JSON.stringify(value)}.`);
}
function _validateString(value: string) {
return value;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/generate-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {

public async run(options: GenerateCommandSchema & Arguments) {
if (!this.schematicName || !this.collectionName) {
return this.printHelp(options);
return this.printHelp();
}

return this.runSchematic({
Expand Down Expand Up @@ -105,8 +105,8 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
return [collectionName, schematicName];
}

public async printHelp(options: GenerateCommandSchema & Arguments) {
await super.printHelp(options);
public async printHelp() {
await super.printHelp();

this.logger.info('');
// Find the generate subcommand.
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export abstract class ArchitectCommand<
return await this.runArchitectTarget(options);
}

protected async runBepTarget<T>(
protected async runBepTarget(
command: string,
configuration: Target,
overrides: json.JsonObject,
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/models/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export abstract class Command<T extends BaseCommandOptions = BaseCommandOptions>
return;
}

async printHelp(options: T & Arguments): Promise<number> {
async printHelp(): Promise<number> {
await this.printHelpUsage();
await this.printHelpOptions();

Expand Down Expand Up @@ -175,7 +175,7 @@ export abstract class Command<T extends BaseCommandOptions = BaseCommandOptions>
await this.initialize(options);

if (options.help === true) {
return this.printHelp(options);
return this.printHelp();
} else if (options.help === 'json' || options.help === 'JSON') {
return this.printJsonHelp(options);
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/models/schematic-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export abstract class SchematicCommand<
}
}

public async printHelp(options: T & Arguments) {
await super.printHelp(options);
public async printHelp() {
await super.printHelp();
this.logger.info('');

const subCommandOption = this.description.options.filter(x => x.subcommands)[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/architect/src/schedule-by-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { analytics, experimental, json, logging } from '@angular-devkit/core';
import { EMPTY, Subscription } from 'rxjs';
import { catchError, first, ignoreElements, map, share, shareReplay, tap } from 'rxjs/operators';
import { catchError, first, ignoreElements, map, shareReplay } from 'rxjs/operators';
import {
BuilderInfo,
BuilderInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Observable } from 'rxjs';
import { map, reduce } from 'rxjs/operators';
import { AggregatedProcessStats, Capture, MetricGroup, MonitoredProcess } from './interfaces';
import { AggregatedProcessStats, Capture, MetricGroup } from './interfaces';
import { cumulativeMovingAverage, max } from './utils';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class NgBuildAnalyticsPlugin {

return metrics;
}
protected _getDimensions(stats: Stats) {
protected _getDimensions() {
const dimensions: (string | number | boolean)[] = [];

if (this._stats.errors.length) {
Expand All @@ -136,13 +136,13 @@ export class NgBuildAnalyticsPlugin {
}

protected _reportBuildMetrics(stats: Stats) {
const dimensions = this._getDimensions(stats);
const dimensions = this._getDimensions();
const metrics = this._getMetrics(stats);
this._analytics.event(this._category, 'build', { dimensions, metrics });
}

protected _reportRebuildMetrics(stats: Stats) {
const dimensions = this._getDimensions(stats);
const dimensions = this._getDimensions();
const metrics = this._getMetrics(stats);
this._analytics.event(this._category, 'rebuild', { dimensions, metrics });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import { Compiler, compilation } from 'webpack';
import { Budget, Type } from '../../browser/schema';
import { Budget } from '../../browser/schema';
import { ProcessBundleResult } from '../../utils/process-bundle';
import { ThresholdSeverity, checkBudgets } from '../utilities/bundle-calculator';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
createBuilder,
targetFromTargetString,
} from '@angular-devkit/architect';
import { JsonObject, join, normalize, resolve } from '@angular-devkit/core';
import { JsonObject, normalize, resolve } from '@angular-devkit/core';
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import * as fs from 'fs';
import * as path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// tslint:disable:no-big-function
import { Architect } from '@angular-devkit/architect';
import { TestLogger } from '@angular-devkit/architect/testing';
import { join, logging, normalize, virtualFs } from '@angular-devkit/core';
import { join, normalize, virtualFs } from '@angular-devkit/core';
import { debounceTime, take, takeWhile, tap } from 'rxjs/operators';
import {
createArchitect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import { Architect } from '@angular-devkit/architect';
import { TestLogger } from '@angular-devkit/architect/testing';
import { logging } from '@angular-devkit/core';
import { browserBuild, createArchitect, host } from '../../test-utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { Architect } from '@angular-devkit/architect';
import * as path from 'path';
import { browserBuild, createArchitect, host, veEnabled } from '../../test-utils';
import { browserBuild, createArchitect, host } from '../../test-utils';

describe('Browser Builder external source map', () => {
const target = { project: 'app', target: 'build' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
* 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 { Observable, from, of } from 'rxjs';
import { Observable, from } from 'rxjs';
import { concatMap, first } from 'rxjs/operators';
import { JsonValue, schema } from '../../json';
import { JobDescription, JobHandler, JobName, Registry, isJobHandler } from './api';
import { JobNameAlreadyRegisteredException } from './exception';
import { JsonValue } from '../../json';
import { JobHandler, JobName, Registry } from './api';


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
// tslint:disable:no-big-function no-non-null-assertion
import { EMPTY, Observable, of, timer } from 'rxjs';
import { map, take, toArray } from 'rxjs/operators';
import { JobHandlerContext, JobOutboundMessage, JobOutboundMessageKind, JobState } from './api';
import { createJobHandler } from './create-job-handler';
import { SimpleJobRegistry } from './simple-registry';
import { SimpleScheduler } from './simple-scheduler';

describe('SimpleJobRegistry', () => {
let registry: SimpleJobRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ export class SimpleScheduler<
handler: Observable<JobHandlerWithExtra | null>,
inboundBus: Observer<JobInboundMessage<I>>,
outboundBus: Observable<JobOutboundMessage<O>>,
options: ScheduleJobOptions,
): Job<A, I, O> {
const schemaRegistry = this._schemaRegistry;

Expand Down Expand Up @@ -541,6 +540,6 @@ export class SimpleScheduler<
),
);

return this._createJob(name, argument, handler, inboundBus, outboundBus, options);
return this._createJob(name, argument, handler, inboundBus, outboundBus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export namespace strategy {
O extends JsonValue = JsonValue,
>(replayMessages = false): JobStrategy<A, I, O> {
let inboundBus = new Subject<JobInboundMessage<I>>();
let runContext: JobHandlerContext | null = null;
let run: Observable<JobOutboundMessage<O>> | null = null;
let state: JobOutboundMessage<O> | null = null;

Expand Down Expand Up @@ -108,7 +107,6 @@ export namespace strategy {
),
replayMessages ? shareReplay() : share(),
);
runContext = context;

return run;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import { existsSync } from 'fs';
import * as path from 'path';
import { Observable, of, throwError } from 'rxjs';
import { concatMap, first, map, tap } from 'rxjs/operators';
import { BaseException } from '../../exception';
Expand Down
8 changes: 2 additions & 6 deletions packages/angular_devkit/schematics/src/rules/base_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ describe('chain', () => {
describe('apply', () => {
it('works with simple rules', done => {
const rulesCalled: Tree[] = [];
let sourceCalled = false;

const tree0 = empty();
const tree1 = empty();
const tree2 = empty();
const tree3 = empty();

const source: Source = () => (sourceCalled = true, tree0);
const source: Source = () => tree0;
const rule0: Rule = (tree: Tree) => (rulesCalled[0] = tree, tree1);
const rule1: Rule = (tree: Tree) => (rulesCalled[1] = tree, tree2);
const rule2: Rule = (tree: Tree) => (rulesCalled[2] = tree, tree3);
Expand All @@ -108,14 +106,12 @@ describe('apply', () => {

it('works with observable rules', done => {
const rulesCalled: Tree[] = [];
let sourceCalled = false;

const tree0 = empty();
const tree1 = empty();
const tree2 = empty();
const tree3 = empty();

const source: Source = () => (sourceCalled = true, tree0);
const source: Source = () => tree0;
const rule0: Rule = (tree: Tree) => (rulesCalled[0] = tree, observableOf(tree1));
const rule1: Rule = (tree: Tree) => (rulesCalled[1] = tree, observableOf(tree2));
const rule2: Rule = (tree: Tree) => (rulesCalled[2] = tree, tree3);
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/schematics/src/workflow/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { logging, schema, virtualFs } from '@angular-devkit/core';
import { EMPTY, Observable, Subject, concat, from, of, throwError } from 'rxjs';
import { concatMap, defaultIfEmpty, ignoreElements, last, map, tap } from 'rxjs/operators';
import { concatMap, defaultIfEmpty, ignoreElements, last, tap } from 'rxjs/operators';
import { Engine, EngineHost, SchematicEngine } from '../engine';
import { UnsuccessfulWorkflowExecution } from '../exception/exception';
import { standardFormats } from '../formats';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Observable, of as observableOf, throwError } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { Url } from 'url';
import {
Collection,
CollectionDescription,
EngineHost,
RuleFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
UnregisteredTaskException,
} from '../src';
import {
FileSystemCollection,
FileSystemCollectionDesc,
FileSystemEngineHost,
FileSystemSchematicContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
// tslint:disable:no-implicit-dependencies
import { schema } from '@angular-devkit/core';
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
import * as path from 'path';
Expand Down
1 change: 0 additions & 1 deletion packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,6 @@ export class AngularCompilerPlugin {
// Report any diagnostics.
reportDiagnostics(
diagnostics,
this._compilerHost,
msg => this._errors.push(new Error(msg)),
msg => this._warnings.push(msg),
);
Expand Down
1 change: 0 additions & 1 deletion packages/ngtools/webpack/src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export function gatherDiagnostics(

export function reportDiagnostics(
diagnostics: Diagnostics,
compilerHost: WebpackCompilerHost & CompilerHost,
reportError: (msg: string) => void,
reportWarning: (msg: string) => void,
) {
Expand Down
2 changes: 0 additions & 2 deletions packages/ngtools/webpack/src/type_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Program,
createCompilerHost,
createProgram,
formatDiagnostics,
} from '@angular/compiler-cli';
import * as ts from 'typescript';
import { time, timeEnd } from './benchmark';
Expand Down Expand Up @@ -111,7 +110,6 @@ export class TypeChecker {
if (!cancellationToken.isCancellationRequested()) {
reportDiagnostics(
allDiagnostics,
this._compilerHost,
msg => this.sendMessage(new LogMessage('error', 'ERROR in ' + msg)),
msg => this.sendMessage(new LogMessage('warn', 'WARNING in ' + msg)),
);
Expand Down
18 changes: 0 additions & 18 deletions packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {
JsonAstObject,
JsonObject,
JsonParseMode,
JsonValue,
join,
normalize,
parseJsonAst,
strings,
} from '@angular-devkit/core';
import {
Expand Down Expand Up @@ -73,20 +69,6 @@ function addDependenciesToPackageJson(options: ApplicationOptions) {
};
}

function readTsLintConfig(host: Tree, path: string): JsonAstObject {
const buffer = host.read(path);
if (!buffer) {
throw new SchematicsException(`Could not read ${path}.`);
}

const config = parseJsonAst(buffer.toString(), JsonParseMode.Loose);
if (config.kind !== 'object') {
throw new SchematicsException(`Invalid ${path}. Was expecting an object.`);
}

return config;
}

/**
* Merges the application tslint.json with the workspace tslint.json
* when the application being created is a root application
Expand Down
Loading

0 comments on commit 05588fc

Please sign in to comment.