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

Commit

Permalink
lint, tooling, and other misc. changes (#304)
Browse files Browse the repository at this point in the history
* Remove jshint files and devDependency
* Update tslint config. Use typechecked lint. Remove options that are subsumed
  by the compiler now.
* Start shipping type definitions.
* Address newly found lint errors.
* Formatting.
  • Loading branch information
ofrobots authored Jul 7, 2017
1 parent dd8ef67 commit f13d122
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 104 deletions.
4 changes: 0 additions & 4 deletions .jshintignore

This file was deleted.

27 changes: 0 additions & 27 deletions .jshintrc

This file was deleted.

4 changes: 0 additions & 4 deletions bin/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ while true; do
shift
done

# Lint
# TODO: Re-enable this when the transition to Typescript is complete
# $(npm bin)/jshint . || exit 1

# Get test/coverage command
counter=0
function run {
Expand Down
10 changes: 7 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ gulp.task('format', () => {
});

gulp.task('test.check-lint', () => {
const program = require('tslint').Linter.createProgram('./tsconfig.json');
return gulp.src(sources)
.pipe(tslint(
{configuration: tslintPath, formatter: 'verbose'}))
.pipe(tslint.report())
.pipe(tslint(
{
configuration: tslintPath,
formatter: 'prose', program
}))
.pipe(tslint.report())
.on('warning', onError);
});

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"author": "Google Inc.",
"description": "Stackdriver Debug Agent for Node.js",
"main": "./build/src/index.js",
"types": "./build/types/index.d.ts",
"repository": "googlecloudplatform/cloud-debug-nodejs",
"keywords": [
"google",
Expand Down Expand Up @@ -41,7 +42,6 @@
"gulp-tslint": "^8.1.1",
"gulp-typescript": "^3.1.6",
"istanbul": "^0.4.1",
"jshint": "^2.7.0",
"merge2": "^1.0.3",
"mocha": "^3.0.0",
"nock": "^9.0.0",
Expand Down Expand Up @@ -74,6 +74,7 @@
"CHANGELOG.md",
"LICENSE",
"README.md",
"build/src"
"build/src",
"build/types"
]
}
42 changes: 21 additions & 21 deletions src/agent/sourcemapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ export interface MapInfoOutput {
column?: number;
}

export function create(
sourcemapPaths: string[],
callback: (err: Error|null, mapper?: SourceMapper) => void): void {
const mapper = new SourceMapper();
const callList =
Array.prototype.slice.call(sourcemapPaths).map(function(p: string) {
return function(cb: (err: Error|null) => void) {
processSourcemap(mapper.infoMap_, p, cb);
};
});

async.parallelLimit(callList, 10, function(err) {
if (err) {
return callback(new Error(
'An error occurred while processing the sourcemap files' + err));
}

callback(null, mapper);
});
}

/**
* @param {!Map} infoMap The map that maps input source files to
* SourceMapConsumer objects that are used to calculate mapping information
Expand Down Expand Up @@ -236,3 +215,24 @@ export class SourceMapper {
};
}
}

export function create(
sourcemapPaths: string[],
callback: (err: Error|null, mapper?: SourceMapper) => void): void {
const mapper = new SourceMapper();
const callList =
Array.prototype.slice.call(sourcemapPaths).map(function(p: string) {
return function(cb: (err: Error|null) => void) {
processSourcemap(mapper.infoMap_, p, cb);
};
});

async.parallelLimit(callList, 10, function(err) {
if (err) {
return callback(new Error(
'An error occurred while processing the sourcemap files' + err));
}

callback(null, mapper);
});
}
25 changes: 12 additions & 13 deletions src/agent/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ const NATIVE_PROPERTY_MESSAGE_INDEX = 1;
const GETTER_MESSAGE_INDEX = 2;
const ARG_LOCAL_LIMIT_MESSAGE_INDEX = 3;

/**
* Captures the stack and current execution state.
*
* @return an object with stackFrames, variableTable, and
* evaluatedExpressions fields
*/
export function capture(
execState: v8Types.ExecutionState, expressions: string[],
config: DebugAgentConfig, v8: v8Types.Debug): apiTypes.Breakpoint {
return (new StateResolver(execState, expressions, config, v8)).capture_();
}


/**
* Checks that the provided expressions will not have side effects and
* then evaluates the expression in the current execution context.
Expand Down Expand Up @@ -582,3 +569,15 @@ class StateResolver {
export function testAssert(): void {
assert.equal(0, 1);
}

/**
* Captures the stack and current execution state.
*
* @return an object with stackFrames, variableTable, and
* evaluatedExpressions fields
*/
export function capture(
execState: v8Types.ExecutionState, expressions: string[],
config: DebugAgentConfig, v8: v8Types.Debug): apiTypes.Breakpoint {
return (new StateResolver(execState, expressions, config, v8)).capture_();
}
36 changes: 10 additions & 26 deletions src/agent/v8debugapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ export interface V8DebugApi {
numListeners_: () => number;
}

interface BreakPointData {
v8Breakpoint: v8Types.BreakPoint;
// TODO: The code in this method assumes this method exists. Verify that
// is correct.
// TODO: Update this so that `null|` is not needed here.
compile: null|((text: string) => string);
class BreakpointData {
constructor(
public apiBreakpoint: apiTypes.Breakpoint,
public v8Breakpoint: v8Types.BreakPoint,
public parsedCondition: estree.Node,
// TODO: The code in this method assumes that `compile` exists. Verify
// that is correct.
// TODO: Update this so that `null|` is not needed for `compile`.
public compile: null|((src: string) => string)) {}
}

/**
Expand All @@ -99,7 +102,7 @@ export function create(
let logger: Logger|null = null;
let config: DebugAgentConfig|null = null;
let fileStats: ScanStats|null = null;
let breakpoints: {[id: string]: BreakPointData} = {};
let breakpoints: {[id: string]: BreakpointData} = {};
let sourcemapper: SourceMapper|null = null;
// Entries map breakpoint id to { enabled: <bool>, listener: <function> }
// TODO: Determine if the listener type is correct
Expand Down Expand Up @@ -659,25 +662,6 @@ export function create(
}; // intentional !!
}

class BreakpointData {
apiBreakpoint: apiTypes.Breakpoint;
v8Breakpoint: v8Types.BreakPoint;
parsedCondition: estree.Node;
compile: null|((src: string) => string);

/**
* @constructor
*/
constructor(
apiBreakpoint: apiTypes.Breakpoint, v8Breakpoint: v8Types.BreakPoint,
parsedCondition: estree.Node, compile: null|((src: string) => string)) {
this.apiBreakpoint = apiBreakpoint;
this.v8Breakpoint = v8Breakpoint;
this.parsedCondition = parsedCondition;
this.compile = compile;
}
}

function setErrorStatusAndCallback(
fn: (err: Error|null) => void, breakpoint: apiTypes.Breakpoint,
refersTo: apiTypes.Reference, message: string): void {
Expand Down
4 changes: 0 additions & 4 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"indent": [true, "spaces"],
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
"no-arg": true,
"no-conditional-assignment": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-inferrable-types": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"quotemark": [true, "single"],
Expand Down

0 comments on commit f13d122

Please sign in to comment.