Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Add compilerOptions: usedLocals (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Nov 26, 2018
1 parent 04f7649 commit 9158af5
Show file tree
Hide file tree
Showing 20 changed files with 17 additions and 56 deletions.
3 changes: 2 additions & 1 deletion packages/opencensus-core/src/exporters/console-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as loggerTypes from '../common/types';
import {Measure, Measurement, View} from '../stats/types';
import {Measurement, View} from '../stats/types';
import * as modelTypes from '../trace/model/types';

import {ExporterBuffer} from './exporter-buffer';
Expand All @@ -34,6 +34,7 @@ export class NoopExporter implements types.Exporter {
/** Format and sends span data to the console. */
export class ConsoleExporter implements types.Exporter {
/** Buffer object to store the spans. */
// @ts-ignore
private logger: loggerTypes.Logger;
private buffer: ExporterBuffer;

Expand Down
1 change: 0 additions & 1 deletion packages/opencensus-core/src/exporters/exporter-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import * as uuidv4 from 'uuid/v4';
import * as logger from '../common/console-logger';
import * as loggerTypes from '../common/types';
import * as configTypes from '../trace/config/types';
Expand Down
4 changes: 2 additions & 2 deletions packages/opencensus-core/src/stats/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

import * as defaultLogger from '../common/console-logger';
import * as loggerTypes from '../common/types';

import {BucketBoundaries} from './bucket-boundaries';
import {Recorder} from './recorder';
import {AggregationData, AggregationMetadata, AggregationType, CountData, DistributionData, LastValueData, Measure, Measurement, MeasureType, SumData, Tags, View} from './types';
import {AggregationData, AggregationType, Measure, Measurement, Tags, View} from './types';

const RECORD_SEPARATOR = String.fromCharCode(30);
const UNIT_SEPARATOR = String.fromCharCode(31);
Expand Down Expand Up @@ -64,6 +63,7 @@ export class BaseView implements View {
/** true if the view was registered */
registered = false;
/** An object to log information to */
// @ts-ignore
private logger: loggerTypes.Logger;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
*/
import * as path from 'path';
import * as semver from 'semver';

import {logger} from '../../common/console-logger';
import {Logger} from '../../common/types';
import * as modelTypes from '../model/types';

import * as types from './types';

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/opencensus-core/src/trace/model/root-span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
*/

import * as uuid from 'uuid';

import * as logger from '../../common/console-logger';
import {Clock} from '../../internal/clock';

import {Span} from './span';
import {SpanBase} from './span-base';
import * as types from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/opencensus-core/src/trace/model/span-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import {Logger} from '../../common/types';
import {Clock} from '../../internal/clock';
import {randomSpanId} from '../../internal/util';

import * as types from './types';


Expand All @@ -30,6 +29,7 @@ export abstract class SpanBase implements types.Span {
/** Indicates if this span was ended */
private endedLocal = false;
/** Indicates if this span was forced to end */
// @ts-ignore
private truncated = false;
/** The Span ID of this span */
readonly id: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/opencensus-core/src/trace/model/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import * as configTypes from '../config/types';
import {Propagation} from '../propagation/types';
import {SamplerBuilder} from '../sampler/sampler';
import * as samplerTypes from '../sampler/types';

import {RootSpan} from './root-span';
import {Span} from './span';
import * as types from './types';


Expand All @@ -40,6 +38,7 @@ export class CoreTracer implements types.Tracer {
/** A list of end span event listeners */
private eventListenersLocal: types.SpanEventListener[] = [];
/** A list of ended root spans */
// @ts-ignore
private endedTraces: types.RootSpan[] = [];
/** Bit to represent whether trace is sampled or not. */
private readonly IS_SAMPLED = 0x1;
Expand Down
1 change: 0 additions & 1 deletion packages/opencensus-core/src/trace/sampler/sampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import {randomSpanId} from '../../internal/util';
import {Sampler} from './types';

// We use 52-bits as our max number because it remains a javascript "safe
Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/src/trace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*/

import * as exportersTypes from '../exporters/types';

import * as configTypes from './config/types';
import * as modelTypes from './model/types';
import * as samplerTypes from './sampler/types';

/** Main interface for tracing. */
export interface Tracing {
Expand Down
7 changes: 2 additions & 5 deletions packages/opencensus-core/test/test-console-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {ConsoleExporter, NoopExporter} from '../src/exporters/console-exporter';
import {ExporterBuffer} from '../src/exporters/exporter-buffer';
import {RootSpan} from '../src/trace/model/root-span';
import {CoreTracer} from '../src/trace/model/tracer';

Expand Down Expand Up @@ -57,7 +54,7 @@ describe('ConsoleLogExporter', () => {
it('should end a span', () => {
const intercept = require('intercept-stdout');
let capturedText = '';
const unhookIntercept = intercept((txt: string) => {
intercept((txt: string) => {
capturedText += txt;
});

Expand All @@ -82,7 +79,7 @@ describe('ConsoleLogExporter', () => {
it('should publish the rootspans in queue', () => {
const intercept = require('intercept-stdout');
let capturedText = '';
const unhookIntercept = intercept((txt: string) => {
intercept((txt: string) => {
capturedText += txt;
});

Expand Down
5 changes: 1 addition & 4 deletions packages/opencensus-core/test/test-console-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import * as logger from '../src/common/console-logger';
import {ConsoleLogger} from '../src/common/console-logger';
import {Logger} from '../src/common/types';


const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
Expand All @@ -38,7 +35,7 @@ describe('ConsoleLogger', () => {
/** Should create a new ConsoleLogger */
describe('new ConsoleLogger()', () => {
it('should log with default levels', () => {
const consoleLogger = logger.logger();
logger.logger();
assert.equal(LEVELS.length, ConsoleLogger.LEVELS.length);
});

Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/test/test-exporter-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import * as logger from '../src/common/console-logger';
import {NoopExporter} from '../src/exporters/console-exporter';
import {ExporterBuffer} from '../src/exporters/exporter-buffer';
Expand Down
5 changes: 1 addition & 4 deletions packages/opencensus-core/test/test-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {Recorder} from '../src';
import {AggregationType, CountData, DistributionData, LastValueData, Measure, Measurement, MeasureType, MeasureUnit, SumData, Tags} from '../src/stats/types';

Expand Down Expand Up @@ -176,8 +174,7 @@ describe('Recorder', () => {
const updatedAggregationData =
Recorder.addMeasurement(distributionData, measurement) as
DistributionData;

assertDistributionData(distributionData, sentValues);
assertDistributionData(updatedAggregationData, sentValues);
}
});
}
Expand Down
6 changes: 2 additions & 4 deletions packages/opencensus-core/test/test-root-span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {RootSpan} from '../src/trace/model/root-span';
import {Span} from '../src/trace/model/span';
import {CoreTracer} from '../src/trace/model/tracer';
import * as types from '../src/trace/model/types';
import {Annotation, Attributes, Link, MessageEvent, TraceOptions} from '../src/trace/model/types';
import {Annotation, Attributes, Link, TraceOptions} from '../src/trace/model/types';

const tracer = new CoreTracer();

Expand Down Expand Up @@ -165,7 +163,7 @@ describe('RootSpan', () => {
it('should end all spans inside rootspan', () => {
const root = new RootSpan(tracer);
root.start();
const span = root.startChildSpan('spanName', 'spanType');
root.startChildSpan('spanName', 'spanType');
root.end();

for (const span of root.spans) {
Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/test/test-sampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {RootSpan} from '../src/trace/model/root-span';
import {CoreTracer} from '../src/trace/model/tracer';
import {SamplerBuilder} from '../src/trace/sampler/sampler';
Expand Down
4 changes: 1 addition & 3 deletions packages/opencensus-core/test/test-span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {RootSpan} from '../src/trace/model/root-span';
import {Span} from '../src/trace/model/span';
import {CoreTracer} from '../src/trace/model/tracer';
import * as types from '../src/trace/model/types';
import {Annotation, Attributes, Link, MessageEvent} from '../src/trace/model/types';
import {Annotation, Attributes, Link} from '../src/trace/model/types';


// TODO: we should evaluate a way to merge similar test cases between span and
Expand Down
5 changes: 1 addition & 4 deletions packages/opencensus-core/test/test-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {BaseView, Stats, StatsEventListener} from '../src';
import {AggregationType, LastValueData, Measure, Measurement, MeasureType, MeasureUnit, View} from '../src/stats/types';

Expand Down Expand Up @@ -135,7 +133,6 @@ describe('Stats', () => {
describe('record()', () => {
let measure: Measure;
const testExporter = new TestExporter();
let view;
let aggregationData: LastValueData;
before(() => {
measure = stats.createMeasureInt64(measureName, measureUnit);
Expand All @@ -144,7 +141,7 @@ describe('Stats', () => {
beforeEach(() => {
testExporter.clean();
stats.registerExporter(testExporter);
view = stats.createView(
stats.createView(
viewName, measure, AggregationType.LAST_VALUE, tagKeys, description);
});

Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/test/test-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/

import * as assert from 'assert';
import {EventEmitter} from 'events';
import * as uuid from 'uuid';

import {randomSpanId} from '../src/internal/util';
import {TracerConfig} from '../src/trace/config/types';
import {RootSpan} from '../src/trace/model/root-span';
Expand Down
10 changes: 1 addition & 9 deletions packages/opencensus-core/test/test-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
*/

import * as assert from 'assert';
import * as mocha from 'mocha';

import {BaseView} from '../src';
import {AggregationType, CountData, DistributionData, LastValueData, Measure, Measurement, MeasureType, MeasureUnit, SumData, Tags, View} from '../src/stats/types';
import {AggregationType, DistributionData, Measure, Measurement, MeasureType, MeasureUnit, Tags, View} from '../src/stats/types';

/** The order of how close values must be to be considerated almost equal */
const EPSILON = 6;
Expand All @@ -28,12 +27,6 @@ interface AggregationTestCase {
description: string;
}

interface MeasurementsTestCase {
values: number[];
bucketBoundaries: number[];
description: string;
}

function isAlmostEqual(
actual: number, expected: number, epsilon: number): boolean {
return Math.abs(actual - expected) < Math.pow(10, -epsilon);
Expand Down Expand Up @@ -117,7 +110,6 @@ describe('BaseView', () => {
describe('recordMeasurement()', () => {
const measurementValues = [1.1, 2.3, 3.2, 4.3, 5.2];
const bucketBoundaries = [2, 4, 6];
const emptyAggregation = {};
const tags: Tags = {testKey1: 'testValue', testKey2: 'testValue'};

for (const aggregationTestCase of aggregationTestCases) {
Expand Down
3 changes: 2 additions & 1 deletion packages/opencensus-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"pretty": true,
"module": "commonjs",
"target": "es6",
"strictNullChecks": false
"strictNullChecks": false,
"noUnusedLocals": true
},
"include": [
"src/**/*.ts",
Expand Down

0 comments on commit 9158af5

Please sign in to comment.