diff --git a/.github/workflows/checkstyle-linux.yml b/.github/workflows/checkstyle-linux.yml index a59a6d09..7090e8eb 100644 --- a/.github/workflows/checkstyle-linux.yml +++ b/.github/workflows/checkstyle-linux.yml @@ -44,6 +44,8 @@ jobs: mv haxe3_libraries haxe_libraries - name: Run lix download run: npx lix download + - name: Fix haxeshim for "-x" + run: ./fixHaxeshim.sh - name: Print versions run: | npx haxe -version @@ -62,12 +64,15 @@ jobs: run: npx haxe buildSchema.hxml - name: Run neko tests if: matrix.haxe-version == '3.4.7' - run: npx haxe -D codecov_json buildTest.hxml + run: npx haxe -D codecov_json testAndResources.hxml - name: Run eval tests if: matrix.haxe-version != '3.4.7' - run: npx haxe -D codecov_json buildTest.hxml + run: npx haxe -D codecov_json testAndResources.hxml - name: Run Java tests run: npx haxe testJava.hxml + - name: Run Jvm tests + if: matrix.haxe-version != '3.4.7' + run: npx haxe testJvm.hxml - name: Format and upload codeclimate coverage if: success() && matrix.haxe-version == '4.0.5' run: | diff --git a/.travis.yml b/.travis.yml index e41012ee..5a1b47ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ install: - if [[ "$HAXE_VERSION" == "haxe4" ]]; then npx lix download haxe 4.0.5; npx lix use haxe 4.0.5; fi - if [[ "$HAXE_VERSION" == "nightly" ]]; then npx lix download haxe nightly; npx lix use haxe nightly; fi - npx lix download + - ./fixHaxeshim.sh - npx haxe -version - npx neko -version - npx haxelib list @@ -33,8 +34,9 @@ script: - npx haxe buildJS.hxml - if [[ "$HAXE_VERSION" != "nightly" ]]; then npx haxe buildCpp.hxml; fi - npx haxe buildSchema.hxml - - npx haxe -D codecov_json buildTest.hxml + - npx haxe -D codecov_json testAndResources.hxml - npx haxe testJava.hxml + - if [[ "$HAXE_VERSION" != "haxe347" ]]; then npx haxe testJvm.hxml; fi - (cd src; ../cc-test-reporter format-coverage -t lcov ../lcov.info) after_script: diff --git a/CHANGELOG.md b/CHANGELOG.md index a3cfe529..2fb4433c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added support for final in `MagicNumber`, fixes [#494](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/494) ([#495](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/495)) - Fixed handling `OBJECT_DECL` token in `RightCurly`, fixes [#496](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/496) ([#497](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/497)) +- Reorganised build files ([#498](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/498)) ## version 2.6.1 (2019-12-17) diff --git a/build.hxml b/build.hxml index ca1e13fb..08ee19dc 100644 --- a/build.hxml +++ b/build.hxml @@ -1,3 +1,3 @@ -buildGlobal.hxml +build/common.hxml -main checkstyle.Main -neko run.n \ No newline at end of file diff --git a/build/Build.hx b/build/Build.hx index 01d5cc10..31227c40 100644 --- a/build/Build.hx +++ b/build/Build.hx @@ -14,7 +14,11 @@ class Build { callLix("buildDebug.hxml", "runD.n"); callLix("buildJS.hxml", "run.js"); callLix("buildSchema.hxml", "Json schema"); - callLix("buildTest.hxml", "Unittests"); + callLix("testAndResources.hxml", "Unittests neko / eval + generate resoucres"); + callLix("testJava.hxml", "Unittests Java"); + #if haxe4 + callLix("testJvm.hxml", "Unittests Jvm"); + #end Sys.exit(exitCode); } @@ -27,7 +31,7 @@ class Build { public static function callLix(buildFile:String, title:String) { var startTime = Timer.stamp(); var result:Int = Sys.command("npx", ["haxe", buildFile]); - Sys.println('building $title (${Timer.stamp() - startTime})'); + Sys.println('building $title (took ${Timer.stamp() - startTime})'); if (result != 0) { exitCode = result; } diff --git a/buildGlobal.hxml b/build/common.hxml similarity index 100% rename from buildGlobal.hxml rename to build/common.hxml diff --git a/build/commonTest.hxml b/build/commonTest.hxml new file mode 100644 index 00000000..307b6281 --- /dev/null +++ b/build/commonTest.hxml @@ -0,0 +1,8 @@ +build/common.hxml +-cp test +-lib mcover +-lib munit +-lib test-adapter +-D unittest +# -debug +--macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) diff --git a/buildCpp.hxml b/buildCpp.hxml index 7ed55374..0f892ae5 100644 --- a/buildCpp.hxml +++ b/buildCpp.hxml @@ -1,4 +1,4 @@ -buildGlobal.hxml +build/common.hxml # -lib hxcpp-debugger # -D HXCPP_DEBUGGER diff --git a/buildDebug.hxml b/buildDebug.hxml index 4c753af9..2cc8cf61 100644 --- a/buildDebug.hxml +++ b/buildDebug.hxml @@ -1,4 +1,4 @@ -buildGlobal.hxml +build/common.hxml -main checkstyle.Main -debug -neko runD.n \ No newline at end of file diff --git a/buildJS.hxml b/buildJS.hxml index 398a7f4b..1c15769a 100644 --- a/buildJS.hxml +++ b/buildJS.hxml @@ -1,4 +1,4 @@ -buildGlobal.hxml +build/common.hxml -lib hxnodejs -main checkstyle.Main -js haxecheckstyle.js \ No newline at end of file diff --git a/buildSchema.hxml b/buildSchema.hxml index b2b1029f..9c18b67a 100644 --- a/buildSchema.hxml +++ b/buildSchema.hxml @@ -1,3 +1,3 @@ -buildGlobal.hxml +build/common.hxml -cp schema -x SchemaGenerator diff --git a/buildTelemetry.hxml b/buildTelemetry.hxml index 842ccfc6..2dfb7bfa 100644 --- a/buildTelemetry.hxml +++ b/buildTelemetry.hxml @@ -1,4 +1,4 @@ -buildGlobal.hxml +build/common.hxml -lib hxtelemetry -D HXCPP_STACK_TRACE diff --git a/buildTest.hxml b/buildTest.hxml deleted file mode 100644 index 6f0878c2..00000000 --- a/buildTest.hxml +++ /dev/null @@ -1,12 +0,0 @@ -buildGlobal.hxml --cp test --lib mcover --lib munit --lib test-adapter --D unittest --x TestMain ---macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) - --cmd neko run -s src -s test -s schema -s build -p resources/static-analysis.txt --cmd neko run --default-config resources/default-config.json --cmd neko run -c resources/default-config.json \ No newline at end of file diff --git a/fixHaxeshim.sh b/fixHaxeshim.sh new file mode 100755 index 00000000..95728c73 --- /dev/null +++ b/fixHaxeshim.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +git clone --depth 1 -b fix_-x https://github.com/AlexHaxe/haxeshim.git + +(cd haxeshim; npm i lix; npx lix download; npx haxe all.hxml) + +cp haxeshim/bin/*.js node_modules/lix/bin + +rm -rf haxeshim diff --git a/package-lock.json b/package-lock.json index 43609562..278d73b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "lix": { - "version": "15.5.4", - "resolved": "https://registry.npmjs.org/lix/-/lix-15.5.4.tgz", - "integrity": "sha512-abOUxMKCcdoR5WUA8Sos5nE/AuXG02/aHkIwzZ7D3uckBcyvhgGOo0NLlMoZEHCLngtvvJ3QvS2KqQa/o+8Upg==", + "version": "15.8.6", + "resolved": "https://registry.npmjs.org/lix/-/lix-15.8.6.tgz", + "integrity": "sha512-rHvwDuclOOigJlGJ1chplT6zEf4msh90lfmo5em8sX5UoiXcaMMN/DkO5i5TRvkxb9g8EBhFxyjZwEdU/kQCFQ==", "dev": true } } diff --git a/package.json b/package.json index df2e15fb..9f5bc509 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ } ], "devDependencies": { - "lix": "^15.5.4" + "lix": "^15.8.6" }, "bugs": "https://github.com/HaxeCheckstyle/haxe-checkstyle/issues", "license": "MIT" diff --git a/resources/default-config.json b/resources/default-config.json index ed234eb3..fc105995 100644 --- a/resources/default-config.json +++ b/resources/default-config.json @@ -182,11 +182,11 @@ "modifier": "PUBLIC", "requireParams": true, "requireReturn": true, + "ignoreOverride": true, "excludeNames": [ "new", "toString" - ], - "ignoreOverride": true + ] } }, { @@ -219,9 +219,9 @@ "props": { "character": "tab", "ignoreConditionals": false, + "conditionalPolicy": "aligned", "ignoreComments": true, - "wrapPolicy": "larger", - "conditionalPolicy": "aligned" + "wrapPolicy": "larger" } }, { @@ -352,9 +352,9 @@ { "type": "MultipleStringLiterals", "props": { - "ignore": "^\\s+$", "allowDuplicates": 2, - "minLength": 2 + "minLength": 2, + "ignore": "^\\s+$" } }, { @@ -424,7 +424,6 @@ { "type": "OperatorWrap", "props": { - "option": "eol", "tokens": [ "=", "+", @@ -461,7 +460,8 @@ "=>", "++", "--" - ] + ], + "option": "eol" } }, { @@ -544,17 +544,17 @@ "props": { "dotPolicy": "none", "commaPolicy": "after", - "semicolonPolicy": "after", - "allowTrailingComma": false + "allowTrailingComma": false, + "semicolonPolicy": "after" } }, { "type": "SeparatorWrap", "props": { - "option": "eol", "tokens": [ "," - ] + ], + "option": "eol" } }, { @@ -568,13 +568,13 @@ { "type": "Spacing", "props": { + "spaceAroundBinop": true, + "noSpaceAroundUnop": true, "spaceIfCondition": "should", "spaceForLoop": "should", "spaceWhileLoop": "should", "spaceSwitchCase": "should", "spaceCatch": "should", - "spaceAroundBinop": true, - "noSpaceAroundUnop": true, "ignoreRangeOperator": true } }, diff --git a/src/checkstyle/ParserQueue.hx b/src/checkstyle/ParserQueue.hx index 1b84edd4..a3e991f8 100644 --- a/src/checkstyle/ParserQueue.hx +++ b/src/checkstyle/ParserQueue.hx @@ -1,21 +1,7 @@ package checkstyle; -#if ((haxe_ver >= 4.0) && (neko || macro || eval || cpp || hl || java)) -import sys.thread.Mutex; -import sys.thread.Thread; -#elseif neko -import neko.vm.Mutex; -import neko.vm.Thread; -#elseif cpp -import cpp.vm.Mutex; -import cpp.vm.Thread; -#elseif java -import java.vm.Mutex; -import java.vm.Thread; -#else import checkstyle.utils.Mutex; import checkstyle.utils.Thread; -#end class ParserQueue { static inline var SLEEP_TIME:Float = 0.1; diff --git a/src/checkstyle/checks/coding/CodeSimilarityCheck.hx b/src/checkstyle/checks/coding/CodeSimilarityCheck.hx index 11ea8400..b2faff24 100644 --- a/src/checkstyle/checks/coding/CodeSimilarityCheck.hx +++ b/src/checkstyle/checks/coding/CodeSimilarityCheck.hx @@ -1,16 +1,6 @@ package checkstyle.checks.coding; -#if ((haxe_ver >= 4.0) && (neko || macro || eval || cpp || hl || java)) -import sys.thread.Mutex; -#elseif neko -import neko.vm.Mutex; -#elseif cpp -import cpp.vm.Mutex; -#elseif java -import java.vm.Mutex; -#else import checkstyle.utils.Mutex; -#end /** Checks for identical or similar code. diff --git a/src/checkstyle/reporter/ReporterManager.hx b/src/checkstyle/reporter/ReporterManager.hx index 15e8bb1b..458fb14d 100644 --- a/src/checkstyle/reporter/ReporterManager.hx +++ b/src/checkstyle/reporter/ReporterManager.hx @@ -1,18 +1,8 @@ package checkstyle.reporter; -#if ((haxe_ver >= 4.0) && (neko || macro || eval || cpp || hl || java)) -import sys.thread.Mutex; -#elseif neko -import neko.vm.Mutex; -#elseif cpp -import cpp.vm.Mutex; -#elseif java -import java.vm.Mutex; -#else -import checkstyle.utils.Mutex; -#end import checkstyle.CheckMessage; import checkstyle.checks.Category; +import checkstyle.utils.Mutex; class ReporterManager { public static var INSTANCE:ReporterManager = new ReporterManager(); diff --git a/src/checkstyle/utils/ConfigUtils.hx b/src/checkstyle/utils/ConfigUtils.hx index 5702f337..64315825 100644 --- a/src/checkstyle/utils/ConfigUtils.hx +++ b/src/checkstyle/utils/ConfigUtils.hx @@ -2,9 +2,9 @@ package checkstyle.utils; import checkstyle.Checker; import checkstyle.ChecksInfo.CheckInfo; -import checkstyle.config.Config; -import checkstyle.config.CheckConfig; import checkstyle.checks.Check; +import checkstyle.config.CheckConfig; +import checkstyle.config.Config; import haxe.Json; import haxe.ds.ArraySort; import sys.io.File; @@ -86,15 +86,19 @@ class ConfigUtils { "messages", "checker", "placemap", - "metaName" + "metaName", + "ignoreRE" ]; var checkConfig:CheckConfig = { type: check.getModuleName(), props: {} }; - for (prop in Reflect.fields(check)) { + for (prop in Type.getInstanceFields(Type.getClass(check))) { if (propsNotAllowed.contains(prop)) continue; - Reflect.setField(checkConfig.props, prop, Reflect.field(check, prop)); + + var value = Reflect.field(check, prop); + if (Reflect.isFunction(value)) continue; + Reflect.setField(checkConfig.props, prop, value); } return checkConfig; } diff --git a/src/checkstyle/utils/DummyMutex.hx b/src/checkstyle/utils/DummyMutex.hx new file mode 100644 index 00000000..d62b61e3 --- /dev/null +++ b/src/checkstyle/utils/DummyMutex.hx @@ -0,0 +1,9 @@ +package checkstyle.utils; + +class DummyMutex { + public function new() {} + + public function acquire() {} + + public function release() {} +} \ No newline at end of file diff --git a/src/checkstyle/utils/DummyThread.hx b/src/checkstyle/utils/DummyThread.hx new file mode 100644 index 00000000..039e418a --- /dev/null +++ b/src/checkstyle/utils/DummyThread.hx @@ -0,0 +1,7 @@ +package checkstyle.utils; + +class DummyThread { + public static function create(f:Void -> Void) { + f(); + } +} \ No newline at end of file diff --git a/src/checkstyle/utils/Mutex.hx b/src/checkstyle/utils/Mutex.hx index 7d1f01ae..6e6b5972 100644 --- a/src/checkstyle/utils/Mutex.hx +++ b/src/checkstyle/utils/Mutex.hx @@ -1,11 +1,17 @@ package checkstyle.utils; -#if (!neko && !cpp && !hl && !java) -class Mutex { - public function new() {} - - public function acquire() {} - - public function release() {} -} +#if haxe4 +#if (neko || macro || eval || cpp || hl || java) +typedef Mutex = sys.thread.Mutex; +#else +typedef Mutex = DummyMutex; +#end +#elseif neko +typedef Mutex = neko.vm.Mutex; +#elseif cpp +typedef Mutex = cpp.vm.Mutex; +#elseif java +typedef Mutex = java.vm.Mutex; +#else +typedef Mutex = DummyMutex; #end \ No newline at end of file diff --git a/src/checkstyle/utils/Thread.hx b/src/checkstyle/utils/Thread.hx index e4352019..54d2c5f2 100644 --- a/src/checkstyle/utils/Thread.hx +++ b/src/checkstyle/utils/Thread.hx @@ -1,9 +1,17 @@ package checkstyle.utils; -#if (!neko && !cpp && !hl) -class Thread { - public static function create(f:Void -> Void) { - f(); - } -} +#if haxe4 +#if (neko || macro || eval || cpp || hl || java) +typedef Thread = sys.thread.Thread; +#else +typedef Thread = DummyThread; +#end +#elseif neko +typedef Thread = neko.vm.Thread; +#elseif cpp +typedef Thread = cpp.vm.Thread; +#elseif java +typedef Thread = java.vm.Thread; +#else +typedef Thread = DummyThread; #end \ No newline at end of file diff --git a/test.hxml b/test.hxml index 74246c24..13c01013 100644 --- a/test.hxml +++ b/test.hxml @@ -1,9 +1,2 @@ -buildGlobal.hxml --cp test --lib mcover --lib munit --lib test-adapter --D unittest -# -debug ---macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) +build/commonTest.hxml -x TestMain diff --git a/testAndResources.hxml b/testAndResources.hxml new file mode 100644 index 00000000..4b12abe4 --- /dev/null +++ b/testAndResources.hxml @@ -0,0 +1,6 @@ +build/commonTest.hxml +-x TestMain + +-cmd neko run -s src -s test -s schema -s build -p resources/static-analysis.txt +-cmd neko run --default-config resources/default-config.json +-cmd neko run -c resources/default-config.json diff --git a/testJava.hxml b/testJava.hxml index 4647923e..d99fa790 100644 --- a/testJava.hxml +++ b/testJava.hxml @@ -1,12 +1,4 @@ -buildGlobal.hxml --cp test --lib mcover --lib munit --lib test-adapter --D unittest -# -D jvm -# -debug ---macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) +build/commonTest.hxml -java out -main TestMain diff --git a/testJvm.hxml b/testJvm.hxml new file mode 100644 index 00000000..528ac2d2 --- /dev/null +++ b/testJvm.hxml @@ -0,0 +1,7 @@ +build/commonTest.hxml +-D jvm + +-java out +-main TestMain + +-cmd java -jar out/TestMain.jar