Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed null pointer exceptions in C++ builds #476

Merged
merged 2 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
- Fixed Java regexp issue in IndentationCheck ([#468](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/468))
- Fixed empty lines between types with conditionals ([#469](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/469))
- Fixed empty lines before comments with conditionals ([#472](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/472))
- Fixed EFunction changes in Haxe 4rc4
- Fixed EFunction changes in Haxe 4rc4 ([#474](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/474))
- Fixed null pointer references for C++ ([#476](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/476))
- Changed return block indentation [#453](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/453)
- Changed applied formatter [#461](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/461)
- Refactored coverage reporting [#462](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/462)
Expand Down
2 changes: 2 additions & 0 deletions src/checkstyle/checks/Check.hx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Check {
}

function forEachField(cb:Field -> ParentType -> Void) {
if (checker.ast == null) return;
if (checker.ast.decls == null) return;
for (td in checker.ast.decls) {
var fields:Array<Field> = switch (td.decl) {
Expand Down Expand Up @@ -134,6 +135,7 @@ class Check {
}

function isCharPosExtern(pos:Int):Bool {
if (checker.ast == null) return false;
if (checker.ast.decls == null) return false;
for (td in checker.ast.decls) {
switch (td.decl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AvoidInlineConditionalsCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e:Expr) {
if (isPosSuppressed(e.pos)) return;
switch (e.expr) {
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/coding/DefaultComesLastCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DefaultComesLastCheck extends Check {

for (token in acceptableTokens) {
var tokens:Array<TokenTree> = token.filter([Kwd(KwdCase), Kwd(KwdDefault)], FIRST);
if (tokens.length <= 0) continue;
if (tokens[tokens.length - 1].is(Kwd(KwdDefault))) continue;

for (i in 0...tokens.length) {
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/literal/ArrayLiteralCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ArrayLiteralCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e:Expr) {
switch (e.expr) {
case ENew({pack: [], name: "Array"}, _):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/literal/ERegLiteralCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ERegLiteralCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e:Expr) {
if (isPosSuppressed(e.pos)) return;
switch (e.expr) {
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HexadecimalLiteralCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e:Expr) {
switch (e.expr) {
case EConst(CInt(s)):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/naming/LocalVariableNameCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LocalVariableNameCheck extends NameCheckBase<String> {

override function actualRun() {
formatRE = new EReg(format, "");
if (checker.ast == null) return;
checker.ast.walkFile(function(e) {
switch (e.expr) {
case EVars(vars):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/naming/NameCheckBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class NameCheckBase<T> extends Check {
}

function checkClassFields() {
if (checker.ast == null) return;
for (td in checker.ast.decls) {
switch (td.decl) {
case EClass(d):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/size/FileLengthCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FileLengthCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
for (td in checker.ast.decls) {
switch (td.decl) {
case EClass(d):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/type/AnonymousCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AnonymousCheck extends Check {
}

function checkLocalVars() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e) {
switch (e.expr) {
case EVars(vars):
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/type/DynamicCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DynamicCheck extends Check {
}

override function actualRun() {
if (checker.ast == null) return;
ComplexTypeUtils.walkFile(checker.ast, callbackComplexType);
}

Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/type/ReturnCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ReturnCheck extends Check {
}

function checkInlineFunctions() {
if (checker.ast == null) return;
checker.ast.walkFile(function(e) {
switch (e.expr) {
#if (haxe_ver < 4.0)
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/whitespace/ArrayAccessCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ArrayAccessCheck extends Check {
override function actualRun() {
var lastExpr = null;

if (checker.ast == null) return;
checker.ast.walkFile(function(e:Expr) {
if (lastExpr == null) {
lastExpr = e;
Expand Down
4 changes: 2 additions & 2 deletions src/checkstyle/checks/whitespace/ExtendedEmptyLinesCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ExtendedEmptyLinesCheck extends Check {
buildPolicyMap();
var emptyLines:ListOfEmptyLines = detectEmptyLines();
if (max <= 0) max = 1;

checkPackages(emptyLines);
checkImports(emptyLines);
checkTypes(emptyLines);
Expand Down Expand Up @@ -336,7 +335,8 @@ class ExtendedEmptyLinesCheck extends Check {
var brOpen = findTypeBrOpen(typeToken);
if (brOpen == null) return;
checkBetweenToken(emptyLines, typeToken, brOpen, getPolicy(TYPE_DEFINITION), "between type definition and left curly");
var brClose:TokenTree = brOpen.getLastChild();
var brClose:Null<TokenTree> = brOpen.getLastChild();
if (brClose == null) return;
var start:Int = checker.getLinePos(brOpen.pos.max).line;
var end:Int = checker.getLinePos(brClose.pos.min).line;
if (start == end) return;
Expand Down
1 change: 1 addition & 0 deletions src/checkstyle/checks/whitespace/SpacingCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SpacingCheck extends Check {

var lastExpr = null;

if (checker.ast == null) return;
checker.ast.walkFile(function(e) {
if (lastExpr == null) {
lastExpr = e;
Expand Down