Skip to content

Commit

Permalink
Fix comparing explicitly against null (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford authored Jun 27, 2018
1 parent d3e4112 commit acbe4d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mongo/grammar/visitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class MongoVisitor<T> implements mongoVisitor<T> {
}

protected aggregateResult(aggregate: T, nextResult: T): T {
return nextResult === null ? aggregate : nextResult;
return !nextResult ? aggregate : nextResult;
}

shouldVisitNextChild(_node, _currentResult: T): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/services/completionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class CompletionItemsVisitor extends MongoVisitor<Promise<CompletionItem[
if (parserRuleContext instanceof ParserRuleContext) {
let startToken = parserRuleContext.start;
let stopToken = parserRuleContext.stop;
if (stopToken === null || startToken.type === mongoParser.mongoParser.EOF) {
if (!stopToken || startToken.type === mongoParser.mongoParser.EOF) {
stopToken = startToken;
}

Expand All @@ -403,7 +403,7 @@ export class CompletionItemsVisitor extends MongoVisitor<Promise<CompletionItem[
private createRangeAfter(parserRuleContext: ParseTree): Range {
if (parserRuleContext instanceof ParserRuleContext) {
let stopToken = parserRuleContext.stop;
if (stopToken === null) {
if (!stopToken) {
stopToken = parserRuleContext.start;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/azureUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export namespace azureUtils {
export function getResourceGroupFromId(id: string): string {
const matches: RegExpMatchArray | null = id.match(/\/subscriptions\/(.*)\/resourceGroups\/(.*)\/providers\/(.*)\/(.*)/);

if (matches === null || matches.length < 3) {
if (!matches || matches.length < 3) {
throw new Error('Invalid Azure Resource Id');
}

Expand All @@ -16,7 +16,7 @@ export namespace azureUtils {
export function getAccountNameFromId(id: string): string {
const matches: RegExpMatchArray | null = id.match(/\/subscriptions\/(.*)\/resourceGroups\/(.*)\/providers\/(.*)\/databaseAccounts\/(.*)/);

if (matches === null || matches.length < 5) {
if (!matches || matches.length < 5) {
throw new Error('Invalid Azure Resource Id');
}

Expand Down

0 comments on commit acbe4d5

Please sign in to comment.