Skip to content

Commit

Permalink
Fixed code smells reported by SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
lvcabral committed Dec 1, 2023
1 parent 49f0b79 commit a5ccf9f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/brsTypes/components/RoAppMemoryMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class RoAppMemoryMonitor extends BrsComponent implements BrsValue {
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
return this.port === undefined ? BrsInvalid.Instance : this.port;
return this.port ?? BrsInvalid.Instance;
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/brsTypes/components/RoAudioPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class RoAudioPlayer extends BrsComponent implements BrsValue {
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
return this.port === undefined ? BrsInvalid.Instance : this.port;
return this.port ?? BrsInvalid.Instance;
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/brsTypes/components/RoChannelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class RoChannelStore extends BrsComponent implements BrsValue {
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
return this.port === undefined ? BrsInvalid.Instance : this.port;
return this.port ?? BrsInvalid.Instance;
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/brsTypes/components/RoDeviceInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ export class RoDeviceInfo extends BrsComponent implements BrsValue {
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
return this.port === undefined ? BrsInvalid.Instance : this.port;
return this.port ?? BrsInvalid.Instance;
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/brsTypes/components/RoScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export class RoScreen extends BrsComponent implements BrsValue {
returns: ValueKind.Object,
},
impl: (_: Interpreter) => {
return this.port === undefined ? BrsInvalid.Instance : this.port;
return this.port ?? BrsInvalid.Instance;
},
});

Expand Down
12 changes: 8 additions & 4 deletions src/parser/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1561,15 +1561,16 @@ export class Parser {
return new Expr.Literal(previous().literal!, previous().location);
case match(Lexeme.Identifier):
return new Expr.Variable(previous() as Identifier);
case match(Lexeme.LeftParen):
case match(Lexeme.LeftParen): {
let left = previous();
let expr = expression();
let right = consume(
"Unmatched '(' - expected ')' after expression",
Lexeme.RightParen
);
return new Expr.Grouping({ left, right }, expr);
case match(Lexeme.LeftSquare):
}
case match(Lexeme.LeftSquare): {
let elements: Expression[] = [];
let openingSquare = previous();

Expand Down Expand Up @@ -1598,7 +1599,8 @@ export class Parser {

//consume("Expected newline or ':' after array literal", Lexeme.Newline, Lexeme.Colon, Lexeme.Eof);
return new Expr.ArrayLiteral(elements, openingSquare, closingSquare);
case match(Lexeme.LeftBrace):
}
case match(Lexeme.LeftBrace): {
let openingBrace = previous();
let members: Expr.AAMember[] = [];

Expand Down Expand Up @@ -1654,11 +1656,13 @@ export class Parser {
let closingBrace = previous();

return new Expr.AALiteral(members, openingBrace, closingBrace);
case match(Lexeme.Pos, Lexeme.Tab):
}
case match(Lexeme.Pos, Lexeme.Tab): {
let token = Object.assign(previous(), {
kind: Lexeme.Identifier,
}) as Identifier;
return new Expr.Variable(token);
}
case check(Lexeme.Function, Lexeme.Sub):
return anonymousFunction();
default:
Expand Down
1 change: 0 additions & 1 deletion src/stdlib/CreateObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BrsError } from "../Error";
import { Callable, ValueKind, BrsInvalid, BrsString, BrsType, StdlibArgument } from "../brsTypes";
import { BrsObjects } from "../brsTypes/components/BrsObjects";
import { Interpreter } from "../interpreter";
Expand Down

0 comments on commit a5ccf9f

Please sign in to comment.