Skip to content

Commit

Permalink
minor fixes and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adireddy committed Apr 3, 2015
1 parent a4cbdb9 commit 680fee3
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 134 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is for unifying the coding style for different editors and IDEs.
# More information at http://EditorConfig.org
root = true

[*]
indent_style = tab
indent_size = 4
insert_final_newline = false
trim_trailing_whitespace = true

[*.hx]
end_of_line = lf

[*.json]
indent_size = 2
13 changes: 13 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
3 changes: 0 additions & 3 deletions build.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
-lib compiletime:2.5.0
-lib hxargs:3.0.0

--each

--next
-main checkstyle.Main
-neko run.n
19 changes: 10 additions & 9 deletions checkstyle/checks/BlockFormatCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package checkstyle.checks;

import checkstyle.LintMessage.SeverityLevel;

@name("BlockFormatCheck")
@desc("Checks empty blocks {} and first/lines of a block")
@name("BlockFormat")
@desc("Checks empty blocks and first/last lines of a block")
class BlockFormatCheck extends Check {

public var severity:String = "INFO";

var firstLineRE = ~/\{\s*$/;
var lastLineRE = ~/^\s*\}[,;]?/;
var firstLineRE = ~/\{[\/*]?\s*$/;
var lastLineRE = ~/^\s*\}[,;\/*]?/;

override function actualRun() {
ExprUtils.walkFile(_checker.ast, function(e){
Expand All @@ -20,12 +20,13 @@ class BlockFormatCheck extends Check {
case EBlock(_) | EObjectDecl(_):
var lmin =_checker.getLinePos(e.pos.min).line;
var lmax =_checker.getLinePos(e.pos.max).line;
if (lmin != lmax){
if (! firstLineRE.match(_checker.lines[lmin])){
logPos("First line of multiline block should contain only `{'", e.pos, Reflect.field(SeverityLevel, severity));

if (lmin != lmax) {
if (!firstLineRE.match(_checker.lines[lmin])) {
logPos("First line of multiline block should contain only '{'", e.pos, Reflect.field(SeverityLevel, severity));
}
if (! lastLineRE.match(_checker.lines[lmax])){
logPos("Last line of multiline block should contain only `}' and maybe `,' or `;'", e.pos, Reflect.field(SeverityLevel, severity));
if (!lastLineRE.match(_checker.lines[lmax])) {
logPos("Last line of multiline block should contain only '}' and maybe ',' or ';'", e.pos, Reflect.field(SeverityLevel, severity));
}
}
default:
Expand Down
6 changes: 3 additions & 3 deletions checkstyle/checks/LineLengthCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import checkstyle.LintMessage.SeverityLevel;
import haxeparser.Data.Token;

@name("LineLength")
@desc("Max line length (default 120)")
@desc("Max line length (default 80)")
class LineLengthCheck extends Check {

public var severity:String = "WARNING";

public var maxLines:Int = 120;
public var maxCharacters:Int = 80;

override function actualRun() {
for (i in 0 ... _checker.lines.length) {
var line = _checker.lines[i];
if (line.length > maxLines) log('Too long line (> ${maxLines})', i + 1, 1, Reflect.field(SeverityLevel, severity));
if (line.length > maxCharacters) log('Too long line (> ${maxCharacters})', i + 1, 1, Reflect.field(SeverityLevel, severity));
}
}
}
2 changes: 1 addition & 1 deletion checkstyle/checks/ListenerNameCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import checkstyle.LintMessage.SeverityLevel;
import haxeparser.Data.Token;

@name("ListenerName")
@desc("Checks listener function names")
@desc("Checks that listener function names are prefixed with 'on'")
class ListenerNameCheck extends Check {

public var severity:String = "ERROR";
Expand Down
2 changes: 1 addition & 1 deletion checkstyle/checks/SpacingCheck.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import checkstyle.LintMessage.SeverityLevel;
import haxeparser.Data.Token;

@name("Spacing")
@desc("Spacing check on if statement and arounf operators")
@desc("Spacing check on if statement and around operators")
class SpacingCheck extends Check {

public var severity:String = "INFO";
Expand Down
21 changes: 21 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = function (grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),

haxe: {
project: {
hxml: "build.hxml"
}
},

zip: {
"pixi.zip": ["checkstyle/**", "haxelib.json", "run.n"]
}
});

grunt.loadNpmTasks("grunt-haxe");
grunt.loadNpmTasks("grunt-zip");
grunt.loadNpmTasks("grunt-exec");
grunt.registerTask("default", ["haxe", "exec"]);
};
8 changes: 4 additions & 4 deletions haxelib.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "haxelint",
"url": "https://github.com/adireddy/haxe-static-analysis",
"name": "checkstyle",
"url": "https://github.com/adireddy/haxe-checkstyle",
"license": "MIT",
"description": "Static analysis and style checking for Haxe",
"description": "Automated code analysis ideal for projects that want to enforce a coding standard.",
"version": "1.0.0",
"releasenote": "initial release",
"contributors": ["adireddy", "mcheshkov"],
"contributors": ["adireddy"],
"dependencies": {
"haxeparser-substituted": "1.0.1"
}
Expand Down
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "checkstyle",
"version": "1.0.0",
"description": "Automated code analysis ideal for projects that want to enforce a coding standard.",
"repository": {
"type": "git",
"url": "https://github.com/adireddy/haxe-checkstyle"
},
"keywords": [
"checkstyle",
"haxe",
"static",
"analysis",
"style"
],
"author": {
"name": "Adi Reddy Mora",
"email": "[email protected]"
},
"dependencies": {
"grunt": "latest",
"grunt-cli": "latest"
},
"license": "MIT",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-copy": "^0.7.0",
"grunt-exec": "^0.4.6",
"grunt-haxe": "^0.1.12",
"grunt-shell": "^1.1.1",
"grunt-zip": "^0.16.0",
"jsdoc": "^3.2.2"
}
}
Binary file modified run.n
Binary file not shown.
16 changes: 15 additions & 1 deletion test/MultipleChecksTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@ class MultipleChecksTest {
trace("TEST");
}

// Void check
function returnCheck() {
return;
}

// setter/getter check
function set_test() {
trace("TEST");
}

// Block format check
function _blockFormat() { //aa
}

// Listener check
function _listener() {
addEventListener("click", onClick);
}
function onClick() {}
}
Loading

0 comments on commit 680fee3

Please sign in to comment.