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

Remove unused imports and variables #289

Merged
merged 2 commits into from
Sep 9, 2016
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
7 changes: 7 additions & 0 deletions complete.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-cp src
-cp test
-lib haxeparser
-lib compiletime:2.6.0
-lib hxargs
-main checkstyle.Main
-neko run.n
3 changes: 0 additions & 3 deletions src/checkstyle/Checker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,11 @@ class Checker {

function makeLines() {
var code = file.content;
var left = false;
var s = 0;
lines = code.split(lineSeparator);
}

function makeTokens() {
try {
var code = file.content;
tokens = [];
tokenTree = null;
var lexer = new HaxeLexer(bytes, file.name);
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import sys.FileSystem;
import sys.io.File;

using checkstyle.utils.ArrayUtils;
using checkstyle.utils.StringUtils;

class Main {

Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/Check.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package checkstyle.checks;

import haxe.macro.Expr.Position;
import haxe.macro.Expr;
import checkstyle.CheckMessage.SeverityLevel;
import haxeparser.Data;

#if debug
import haxe.CallStack;
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/block/EmptyBlockCheck.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package checkstyle.checks.block;

import checkstyle.token.TokenTree;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/block/LeftCurlyCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.block;

import checkstyle.token.TokenTree;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down Expand Up @@ -170,8 +169,6 @@ class LeftCurlyCheck extends Check {
}

function checkLeftCurly(line:String, wrapped:Bool = false, pos:Position) {
var lineLength:Int = line.length;

// must have at least one non whitespace character before curly
// and only whitespace, /* + comment or // + comment after curly
var curlyAtEOL:Bool = ~/^\s*\S.*\{\s*(|\/\*.*|\/\/.*)$/.match(line);
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/block/NeedBracesCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package checkstyle.checks.block;
import checkstyle.Checker.LinePos;
import checkstyle.token.TokenTree;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/block/RightCurlyCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checkstyle.checks.block;

import checkstyle.Checker.LinePos;
import checkstyle.token.TokenTree;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/coding/HiddenFieldCheck.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package checkstyle.checks.coding;

import checkstyle.token.TokenTree;
import haxeparser.Data.TokenDef;

using checkstyle.utils.ArrayUtils;
using checkstyle.utils.FieldUtils;

@name("HiddenField")
@desc("Checks that a local variable or a parameter does not shadow a field that is defined in the same class.")
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/coding/InnerAssignmentCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.coding;

import checkstyle.token.TokenTree;
import haxe.macro.Expr;
import haxeparser.Data.TokenDef;

@name("InnerAssignment")
Expand Down Expand Up @@ -32,7 +31,6 @@ class InnerAssignmentCheck extends Check {
Binop(OpAssignOp(OpOr)),
Binop(OpAssignOp(OpXor))
], ALL);
var x:Int = 0;
for (assignToken in allAssignments) {
if (isPosSuppressed(assignToken.pos) || !filterAssignment(assignToken)) continue;
logPos("Inner assignment detected", assignToken.pos);
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/coding/NestedForDepthCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.coding;

import haxeparser.Data;
import haxe.macro.Expr;

@name("NestedForDepth")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/coding/NestedIfDepthCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.coding;

import haxeparser.Data;
import haxe.macro.Expr;

@name("NestedIfDepth")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/coding/NestedTryDepthCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.coding;

import haxeparser.Data;
import haxe.macro.Expr;

@name("NestedTryDepth")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.coding;

import checkstyle.token.TokenTree;
import haxe.macro.Expr;

@name("SimplifyBooleanExpression")
@desc("Checks for over-complicated boolean expressions. Finds code like `if (b == true), b || true, !false`, etc.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.coding;

import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/comments/TODOCommentCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.comments;

import checkstyle.CheckMessage.SeverityLevel;
import haxeparser.Data.Token;

@name("TODOComment")
@desc("A check for TODO/FIXME/HACK/XXX/BUG comments. The format can be customised by changing `format` property.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/imports/AvoidStarImportCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.imports;

import checkstyle.token.TokenTree;
import haxe.macro.Expr;

@name("AvoidStarImport")
@desc("Checks for import statements that use the * notation and using directives.")
Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/imports/UnusedImportCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package checkstyle.checks.imports;

import checkstyle.token.TokenTree;
import checkstyle.utils.TokenTreeCheckUtils;
import haxe.macro.Expr;
import haxe.macro.Expr;
import haxe.io.Path;
import haxeparser.Data;

Expand Down Expand Up @@ -93,7 +91,6 @@ class UnusedImportCheck extends Check {
function detectModuleName(token:TokenTree):String {
var moduleName:StringBuf = new StringBuf();

var copy:Bool = false;
while (true) {
switch (token.tok) {
case Binop(OpMult): return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package checkstyle.checks.literal;
import checkstyle.token.TokenTree;
import checkstyle.token.TokenTreeBuilder;
import checkstyle.utils.StringUtils;
import haxe.macro.Expr;

@name("MultipleStringLiterals")
@desc("Checks for multiple occurrences of the same string literal within a single file. Code duplication makes maintenance more difficult, so it's better to replace the multiple occurrences with a constant.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/literal/StringLiteralCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class StringLiteralCheck extends Check {
override function actualRun() {
var root:TokenTree = TokenTreeBuilder.buildTokenTree(checker.tokens, checker.bytes);

var allLiterals:Map<String, Int> = new Map<String, Int>();
var allStringLiterals:Array<TokenTree> = root.filterCallback(function(token:TokenTree, depth:Int):FilterResult {
if (token.tok == null) return GO_DEEPER;
return switch (token.tok) {
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/modifier/ModifierOrderCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.modifier;

import haxeparser.Data;
import haxe.macro.Expr;

@name("ModifierOrder", "AccessOrder")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/modifier/RedundantModifierCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.modifier;

import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/naming/ListenerNameCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package checkstyle.checks.naming;

import checkstyle.utils.ExprUtils;
import haxe.macro.Expr;
import haxe.macro.Expr.Field;
import haxe.macro.Expr.Function;

@name("ListenerName")
@desc("Checks the naming conventions of event listener functions specified using `listeners` property.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/naming/LocalVariableNameCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.naming;

import checkstyle.utils.ExprUtils;
import haxeparser.Data;

@name("LocalVariableName")
@desc("Checks that the local variable names conform to a format specified by the `format` property.")
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/size/FileLengthCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package checkstyle.checks.size;

import haxeparser.Data.Token;

@name("FileLength")
@desc("Checks for long source files. If a source file becomes very long it is hard to understand. Therefore long classes should usually be refactored into several individual classes that focus on a specific task.")
class FileLengthCheck extends Check {
Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/size/MethodCountCheck.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package checkstyle.checks.size;

import checkstyle.token.TokenTree;
import haxeparser.Data;

using checkstyle.utils.ArrayUtils;

@name("MethodCount")
@desc("Checks the number of methods declared in each type. This includes the number of each scope (`private` and `public`) as well as an overall total.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/size/MethodLengthCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package checkstyle.checks.size;
import checkstyle.utils.ExprUtils;
import haxe.macro.Expr;
import haxe.macro.Expr.Field;
import haxe.macro.Expr.Function;

@name("MethodLength")
@desc("Checks for long methods. If a method becomes very long it is hard to understand. Therefore long methods should usually be refactored into several individual methods that focus on a specific task.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/size/ParameterNumberCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.size;

import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/type/AnonymousCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.type;

import checkstyle.utils.ExprUtils;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.FieldUtils;
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/type/DynamicCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.type;

import haxe.macro.Expr;
import haxeparser.Data;
import checkstyle.utils.ComplexTypeUtils;

@name("Dynamic")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/type/ReturnCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checkstyle.checks.type;

import checkstyle.utils.ExprUtils;
import haxe.macro.Expr;
import haxeparser.Data;

using checkstyle.utils.FieldUtils;

Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/type/TypeCheck.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package checkstyle.checks.type;

import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/whitespace/ArrayAccessCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ArrayAccessCheck extends Check {
}

if (!spaceInside) {
var eString = checker.getString(e.pos.min, e.pos.max);
if (checker.file.content.substr(e2.pos.min - 1, 1) == " ") logPos("Space between [ and index", e.pos);
if (checker.file.content.substr(e2.pos.max, 1) == " ") logPos("Space between index and ]", e.pos);
}
Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/whitespace/OperatorWhitespaceCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import checkstyle.utils.TokenTreeCheckUtils;
import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespacePolicy;
import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespaceUnaryPolicy;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

@name("OperatorWhitespace")
@desc("Checks that whitespace is present or absent around a operators.")
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/whitespace/OperatorWrapCheck.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.checks.whitespace;

import haxeparser.Data;
import haxe.macro.Expr;

@name("OperatorWrap")
@desc("Checks line wrapping with operators.")
Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/whitespace/SeparatorWhitespaceCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import checkstyle.Checker.LinePos;
import checkstyle.token.TokenTree;
import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespacePolicy;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

@name("SeparatorWhitespace")
@desc("Checks that whitespace is present or absent around a separators.")
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/checks/whitespace/TabForAligningCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package checkstyle.checks.whitespace;

import checkstyle.CheckMessage.SeverityLevel;

using checkstyle.utils.StringUtils;

@name("TabForAligning")
@desc("Checks if there are any tabs in the middle of a line.")
class TabForAligningCheck extends LineCheckBase {
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/whitespace/WhitespaceAfterCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package checkstyle.checks.whitespace;
import checkstyle.token.TokenTree;
import checkstyle.utils.TokenTreeCheckUtils;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/checks/whitespace/WhitespaceAroundCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import checkstyle.Checker.LinePos;
import checkstyle.token.TokenTree;
import checkstyle.utils.TokenTreeCheckUtils;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

Expand Down
3 changes: 0 additions & 3 deletions src/checkstyle/checks/whitespace/WhitespaceCheckBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import checkstyle.Checker.LinePos;
import checkstyle.token.TokenTree;
import checkstyle.utils.TokenTreeCheckUtils;
import haxeparser.Data;
import haxe.macro.Expr;

using checkstyle.utils.ArrayUtils;

@ignore("base class for OperatorWhitespace and SeparatorWhitespace")
class WhitespaceCheckBase extends Check {
Expand Down
1 change: 0 additions & 1 deletion src/checkstyle/token/TokenStream.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package checkstyle.token;

import byte.ByteData;
import haxe.macro.Expr;
import haxeparser.Data.Token;
import haxeparser.Data.TokenDef;
import hxparse.Position;
Expand Down
2 changes: 0 additions & 2 deletions src/checkstyle/token/TokenTreeBuilder.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package checkstyle.token;

import byte.ByteData;
import haxe.macro.Expr;
import haxeparser.Data.Token;
import haxeparser.Data.TokenDef;

import checkstyle.token.walk.WalkFile;

Expand Down
4 changes: 0 additions & 4 deletions src/checkstyle/token/walk/WalkAbstract.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package checkstyle.token.walk;

import haxe.macro.Expr;
import haxeparser.Data.Token;
import haxeparser.Data.TokenDef;

import checkstyle.token.TokenStream;
import checkstyle.token.TokenStreamProgress;
import checkstyle.token.TokenTree;
Expand Down
4 changes: 0 additions & 4 deletions src/checkstyle/token/walk/WalkArrayAccess.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package checkstyle.token.walk;

import haxe.macro.Expr;
import haxeparser.Data.Token;
import haxeparser.Data.TokenDef;

import checkstyle.token.TokenStream;
import checkstyle.token.TokenStreamProgress;
import checkstyle.token.TokenTree;
Expand Down
Loading