From da3bf91049a0a3eb84665c5b22565d9d725d6bb6 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Tue, 5 Jun 2018 23:58:28 +0200 Subject: [PATCH] Json schema (#431) * generate json schemas for checkstyle config files --- CHANGES.md | 2 + buildAll.hxml | 4 + buildSchema.hxml | 3 + buildTest.hxml | 2 +- checkstyle.json | 4 + resources/checkstyle-excludes-schema.json | 309 ++ resources/checkstyle-schema.json | 3362 +++++++++++++++++++++ schema/CheckstyleSchemaGenerator.hx | 145 + schema/JsonSchemaGenerator.hx | 156 + schema/ObjectDeclField.hx | 13 + schema/SchemaGenerator.hx | 18 + schema/SchemaUtils.hx | 35 + schema/StructInfo.hx | 4 + src/checkstyle/config/ConfigParser.hx | 2 +- src/checkstyle/config/ExcludeConfig.hx | 6 +- 15 files changed, 4061 insertions(+), 4 deletions(-) create mode 100644 buildSchema.hxml create mode 100644 resources/checkstyle-excludes-schema.json create mode 100644 resources/checkstyle-schema.json create mode 100644 schema/CheckstyleSchemaGenerator.hx create mode 100644 schema/JsonSchemaGenerator.hx create mode 100644 schema/ObjectDeclField.hx create mode 100644 schema/SchemaGenerator.hx create mode 100644 schema/SchemaUtils.hx create mode 100644 schema/StructInfo.hx diff --git a/CHANGES.md b/CHANGES.md index 79621e62..e7df9c72 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ ## dev branch / next version (2.x.x) +- Added JSON schemas for `checkstyle.json` and `checkstyle-exclude.json` file formats [#431](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/431) + ## version 2.4.0 (2018-06-02) - New check ExtendedEmptyLines [#426](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/426) + [#427](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/427) diff --git a/buildAll.hxml b/buildAll.hxml index 3e71d9e1..9477ca39 100644 --- a/buildAll.hxml +++ b/buildAll.hxml @@ -6,4 +6,8 @@ buildDebug.hxml --next +buildSchema.hxml + +--next + buildTest.hxml \ No newline at end of file diff --git a/buildSchema.hxml b/buildSchema.hxml new file mode 100644 index 00000000..b2b1029f --- /dev/null +++ b/buildSchema.hxml @@ -0,0 +1,3 @@ +buildGlobal.hxml +-cp schema +-x SchemaGenerator diff --git a/buildTest.hxml b/buildTest.hxml index edd384fe..2026295e 100644 --- a/buildTest.hxml +++ b/buildTest.hxml @@ -6,6 +6,6 @@ buildGlobal.hxml --macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) --next --cmd neko run -s src -s test -p resources/static-analysis.txt +-cmd neko run -s src -s test -s schema -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/checkstyle.json b/checkstyle.json index c0926f8b..72b1833b 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -554,6 +554,7 @@ ], "MultipleStringLiterals": [ "checks", + "schema", "token" ], "CyclomaticComplexity": [ @@ -593,6 +594,9 @@ ], "MemberName": [ "checkstyle/Main" + ], + "UnusedLocalVar": [ + "JsonSchemaGenerator" ] } } \ No newline at end of file diff --git a/resources/checkstyle-excludes-schema.json b/resources/checkstyle-excludes-schema.json new file mode 100644 index 00000000..4cb95bad --- /dev/null +++ b/resources/checkstyle-excludes-schema.json @@ -0,0 +1,309 @@ +{ + "id": "https://raw.githubusercontent.com/HaxeCheckstyle/haxe-checkstyle/dev/resources/checkstyle-excludes-schema.json", + "$ref": "#/definitions/ExcludeConfig", + "$schema": "http://json-schema.org/schema#", + "definitions": { + "ExcludeFilterList": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ExcludeConfig": { + "type": "object", + "properties": { + "RightCurly": { + "propertyOrder": 52, + "$ref": "#/definitions/ExcludeFilterList" + }, + "path": { + "enum": [ + "RELATIVE_TO_PROJECT", + "RELATIVE_TO_SOURCE" + ], + "type": "string", + "propertyOrder": 0 + }, + "CatchParameterName": { + "propertyOrder": 9, + "$ref": "#/definitions/ExcludeFilterList" + }, + "VariableInitialisation": { + "propertyOrder": 68, + "$ref": "#/definitions/ExcludeFilterList" + }, + "HexadecimalLiteral": { + "propertyOrder": 21, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodLength": { + "propertyOrder": 34, + "$ref": "#/definitions/ExcludeFilterList" + }, + "HiddenField": { + "propertyOrder": 22, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodCount": { + "propertyOrder": 33, + "$ref": "#/definitions/ExcludeFilterList" + }, + "RedundantModifier": { + "propertyOrder": 49, + "$ref": "#/definitions/ExcludeFilterList" + }, + "PublicAccessor": { + "propertyOrder": 48, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedIfDepth": { + "propertyOrder": 41, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Interface": { + "propertyOrder": 26, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ArrayAccess": { + "propertyOrder": 5, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MagicNumber": { + "propertyOrder": 31, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Spacing": { + "propertyOrder": 57, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnusedImport": { + "propertyOrder": 66, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyPackage": { + "propertyOrder": 18, + "$ref": "#/definitions/ExcludeFilterList" + }, + "OperatorWhitespace": { + "propertyOrder": 44, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NeedBraces": { + "propertyOrder": 39, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ParameterName": { + "propertyOrder": 46, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LineLength": { + "propertyOrder": 28, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyLines": { + "propertyOrder": 17, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MultipleVariableDeclarations": { + "propertyOrder": 38, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ERegLiteral": { + "propertyOrder": 15, + "$ref": "#/definitions/ExcludeFilterList" + }, + "AvoidInlineConditionals": { + "propertyOrder": 7, + "$ref": "#/definitions/ExcludeFilterList" + }, + "WhitespaceAfter": { + "propertyOrder": 69, + "$ref": "#/definitions/ExcludeFilterList" + }, + "FileLength": { + "propertyOrder": 20, + "$ref": "#/definitions/ExcludeFilterList" + }, + "AvoidStarImport": { + "propertyOrder": 8, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ModifierOrder": { + "propertyOrder": 36, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ExtendedEmptyLines": { + "propertyOrder": 19, + "$ref": "#/definitions/ExcludeFilterList" + }, + "version": { + "minimum": 1, + "type": "integer", + "maximum": 1, + "propertyOrder": 2 + }, + "SeparatorWrap": { + "propertyOrder": 54, + "$ref": "#/definitions/ExcludeFilterList" + }, + "WhitespaceAround": { + "propertyOrder": 70, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ListenerName": { + "propertyOrder": 29, + "$ref": "#/definitions/ExcludeFilterList" + }, + "": { + "propertyOrder": 3, + "$ref": "#/definitions/ExcludeFilterList" + }, + "CyclomaticComplexity": { + "propertyOrder": 12, + "$ref": "#/definitions/ExcludeFilterList" + }, + "all": { + "propertyOrder": 1, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SimplifyBooleanExpression": { + "propertyOrder": 55, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SeparatorWhitespace": { + "propertyOrder": 53, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TrailingWhitespace": { + "propertyOrder": 62, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Dynamic": { + "propertyOrder": 14, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LeftCurly": { + "propertyOrder": 27, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ParameterNumber": { + "propertyOrder": 47, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodName": { + "propertyOrder": 35, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnusedLocalVar": { + "propertyOrder": 67, + "$ref": "#/definitions/ExcludeFilterList" + }, + "IndentationCharacter": { + "propertyOrder": 24, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ArrayLiteral": { + "propertyOrder": 6, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MemberName": { + "propertyOrder": 32, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TypeName": { + "propertyOrder": 64, + "$ref": "#/definitions/ExcludeFilterList" + }, + "InnerAssignment": { + "propertyOrder": 25, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnnecessaryConstructor": { + "propertyOrder": 65, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MultipleStringLiterals": { + "propertyOrder": 37, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Anonymous": { + "propertyOrder": 4, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedTryDepth": { + "propertyOrder": 42, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SimplifyBooleanReturn": { + "propertyOrder": 56, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TODOComment": { + "propertyOrder": 59, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ConstantName": { + "propertyOrder": 11, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Trace": { + "propertyOrder": 61, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NullableParameter": { + "propertyOrder": 43, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TabForAligning": { + "propertyOrder": 60, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyBlock": { + "propertyOrder": 16, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedForDepth": { + "propertyOrder": 40, + "$ref": "#/definitions/ExcludeFilterList" + }, + "StringLiteral": { + "propertyOrder": 58, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ConditionalCompilation": { + "propertyOrder": 10, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Type": { + "propertyOrder": 63, + "$ref": "#/definitions/ExcludeFilterList" + }, + "OperatorWrap": { + "propertyOrder": 45, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ReturnCount": { + "propertyOrder": 51, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Indentation": { + "propertyOrder": 23, + "$ref": "#/definitions/ExcludeFilterList" + }, + "DefaultComesLast": { + "propertyOrder": 13, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Return": { + "propertyOrder": 50, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LocalVariableName": { + "propertyOrder": 30, + "$ref": "#/definitions/ExcludeFilterList" + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/resources/checkstyle-schema.json b/resources/checkstyle-schema.json new file mode 100644 index 00000000..3743fa2b --- /dev/null +++ b/resources/checkstyle-schema.json @@ -0,0 +1,3362 @@ +{ + "id": "https://raw.githubusercontent.com/HaxeCheckstyle/haxe-checkstyle/dev/resources/checkstyle-schema.json", + "$ref": "#/definitions/Config", + "$schema": "http://json-schema.org/schema#", + "definitions": { + "HexadecimalLiteralCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "option": { + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "HexadecimalLiteral" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ERegLiteralCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ERegLiteral" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "NestedForDepthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "NestedForDepth" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "DynamicCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Dynamic" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "UnusedImportCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "moduleTypeMap": { + "type": "object", + "propertyOrder": 1 + }, + "ignoreModules": { + "items": { + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "UnusedImport" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "HiddenFieldCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignoreSetter": { + "type": "boolean", + "propertyOrder": 1 + }, + "ignoreFormat": { + "type": "string", + "propertyOrder": 2 + }, + "ignoreConstructorParameter": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "HiddenField" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "InterfaceCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "allowProperties": { + "type": "boolean", + "propertyOrder": 1 + }, + "allowMarkerInterfaces": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Interface" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "AvoidInlineConditionalsCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "AvoidInlineConditionals" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "PublicAccessorCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "PublicAccessor" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "IndentationCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "character": { + "enum": [ + "tab", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ], + "type": "string", + "propertyOrder": 0 + }, + "wrapPolicy": { + "enum": [ + "none", + "exact", + "larger" + ], + "type": "string", + "propertyOrder": 4 + }, + "ignoreComments": { + "type": "boolean", + "propertyOrder": 3 + }, + "ignoreConditionals": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 5 + }, + "conditionalPolicy": { + "enum": [ + "ignore", + "fixed_zero", + "aligned", + "aligned_increase" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Indentation" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "CyclomaticComplexityCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "thresholds": { + "items": { + "$ref": "#/definitions/Threshold" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "CyclomaticComplexity" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "OperatorWrapCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "OperatorWrap" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MethodNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MethodName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "StringLiteralCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "policy": { + "enum": [ + "onlySingle", + "onlyDouble", + "doubleAndInterpolation" + ], + "type": "string", + "propertyOrder": 0 + }, + "allowException": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "StringLiteral" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ListenerNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "listeners": { + "items": { + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "format": { + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ListenerName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MemberNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MemberName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "Threshold": { + "type": "object", + "properties": { + "complexity": { + "type": "integer", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false, + "required": [ + "severity", + "complexity" + ] + }, + "EmptyBlockCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "tokens": { + "items": { + "enum": [ + "CLASS_DEF", + "ENUM_DEF", + "ABSTRACT_DEF", + "TYPEDEF_DEF", + "INTERFACE_DEF", + "OBJECT_DECL", + "FUNCTION", + "FOR", + "IF", + "WHILE", + "SWITCH", + "TRY", + "CATCH", + "REIFICATION" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "option": { + "enum": [ + "empty", + "text", + "stmt" + ], + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "EmptyBlock" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ArrayAccessCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "spaceBefore": { + "type": "boolean", + "propertyOrder": 0 + }, + "spaceInside": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ArrayAccess" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ReturnCountCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignoreFormat": { + "type": "string", + "propertyOrder": 1 + }, + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ReturnCount" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "NestedTryDepthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "NestedTryDepth" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "LeftCurlyCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "tokens": { + "items": { + "enum": [ + "CLASS_DEF", + "ENUM_DEF", + "ABSTRACT_DEF", + "TYPEDEF_DEF", + "INTERFACE_DEF", + "OBJECT_DECL", + "FUNCTION", + "FOR", + "IF", + "WHILE", + "SWITCH", + "TRY", + "CATCH", + "REIFICATION", + "ARRAY_COMPREHENSION" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "ignoreEmptySingleline": { + "type": "boolean", + "propertyOrder": 2 + }, + "option": { + "enum": [ + "eol", + "nl", + "nlow" + ], + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "LeftCurly" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MagicNumberCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignoreNumbers": { + "items": { + "type": "number" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MagicNumber" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "LocalVariableNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "LocalVariableName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "IndentationCharacterCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "character": { + "enum": [ + "tab", + "space" + ], + "type": "string", + "propertyOrder": 0 + }, + "ignorePattern": { + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "IndentationCharacter" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MultipleVariableDeclarationsCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MultipleVariableDeclarations" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MultipleStringLiteralsCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "minLength": { + "type": "integer", + "propertyOrder": 1 + }, + "ignore": { + "type": "string", + "propertyOrder": 2 + }, + "allowDuplicates": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MultipleStringLiterals" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "NullableParameterCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "option": { + "enum": [ + "questionMark", + "nullDefault" + ], + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "NullableParameter" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "OperatorWhitespaceCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ternaryOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 2 + }, + "unaryOpPolicy": { + "enum": [ + "inner", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 1 + }, + "boolOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 6 + }, + "intervalOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 7 + }, + "assignOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 0 + }, + "functionArgPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 9 + }, + "bitwiseOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 5 + }, + "arithmeticOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 3 + }, + "compareOpPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 4 + }, + "arrowPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 8 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 10 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "OperatorWhitespace" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ExtendedEmptyLinesCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "none": { + "items": { + "enum": [ + "beforePackage", + "afterPackage", + "betweenImports", + "beforeUsing", + "afterImports", + "anywhereInFile", + "betweenTypes", + "beforeFileEnd", + "inFunction", + "afterLeftCurly", + "beforeRightCurly", + "typeDefinition", + "beginClass", + "endClass", + "afterClassStaticVars", + "afterClassVars", + "betweenClassStaticVars", + "betweenClassVars", + "betweenClassMethods", + "beginAbstract", + "endAbstract", + "afterAbstractVars", + "betweenAbstractVars", + "betweenAbstractMethods", + "beginInterface", + "endInterface", + "betweenInterfaceFields", + "beginEnum", + "endEnum", + "betweenEnumFields", + "beginTypedef", + "endTypedef", + "betweenTypedefFields", + "afterSingleLineComment", + "afterMultiLineComment" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 4 + }, + "upto": { + "items": { + "enum": [ + "beforePackage", + "afterPackage", + "betweenImports", + "beforeUsing", + "afterImports", + "anywhereInFile", + "betweenTypes", + "beforeFileEnd", + "inFunction", + "afterLeftCurly", + "beforeRightCurly", + "typeDefinition", + "beginClass", + "endClass", + "afterClassStaticVars", + "afterClassVars", + "betweenClassStaticVars", + "betweenClassVars", + "betweenClassMethods", + "beginAbstract", + "endAbstract", + "afterAbstractVars", + "betweenAbstractVars", + "betweenAbstractMethods", + "beginInterface", + "endInterface", + "betweenInterfaceFields", + "beginEnum", + "endEnum", + "betweenEnumFields", + "beginTypedef", + "endTypedef", + "betweenTypedefFields", + "afterSingleLineComment", + "afterMultiLineComment" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 6 + }, + "defaultPolicy": { + "enum": [ + "ignore", + "none", + "exact", + "upto", + "atleast" + ], + "type": "string", + "propertyOrder": 2 + }, + "exact": { + "items": { + "enum": [ + "beforePackage", + "afterPackage", + "betweenImports", + "beforeUsing", + "afterImports", + "anywhereInFile", + "betweenTypes", + "beforeFileEnd", + "inFunction", + "afterLeftCurly", + "beforeRightCurly", + "typeDefinition", + "beginClass", + "endClass", + "afterClassStaticVars", + "afterClassVars", + "betweenClassStaticVars", + "betweenClassVars", + "betweenClassMethods", + "beginAbstract", + "endAbstract", + "afterAbstractVars", + "betweenAbstractVars", + "betweenAbstractMethods", + "beginInterface", + "endInterface", + "betweenInterfaceFields", + "beginEnum", + "endEnum", + "betweenEnumFields", + "beginTypedef", + "endTypedef", + "betweenTypedefFields", + "afterSingleLineComment", + "afterMultiLineComment" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 5 + }, + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "ignore": { + "items": { + "enum": [ + "beforePackage", + "afterPackage", + "betweenImports", + "beforeUsing", + "afterImports", + "anywhereInFile", + "betweenTypes", + "beforeFileEnd", + "inFunction", + "afterLeftCurly", + "beforeRightCurly", + "typeDefinition", + "beginClass", + "endClass", + "afterClassStaticVars", + "afterClassVars", + "betweenClassStaticVars", + "betweenClassVars", + "betweenClassMethods", + "beginAbstract", + "endAbstract", + "afterAbstractVars", + "betweenAbstractVars", + "betweenAbstractMethods", + "beginInterface", + "endInterface", + "betweenInterfaceFields", + "beginEnum", + "endEnum", + "betweenEnumFields", + "beginTypedef", + "endTypedef", + "betweenTypedefFields", + "afterSingleLineComment", + "afterMultiLineComment" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 3 + }, + "atleast": { + "items": { + "enum": [ + "beforePackage", + "afterPackage", + "betweenImports", + "beforeUsing", + "afterImports", + "anywhereInFile", + "betweenTypes", + "beforeFileEnd", + "inFunction", + "afterLeftCurly", + "beforeRightCurly", + "typeDefinition", + "beginClass", + "endClass", + "afterClassStaticVars", + "afterClassVars", + "betweenClassStaticVars", + "betweenClassVars", + "betweenClassMethods", + "beginAbstract", + "endAbstract", + "afterAbstractVars", + "betweenAbstractVars", + "betweenAbstractMethods", + "beginInterface", + "endInterface", + "betweenInterfaceFields", + "beginEnum", + "endEnum", + "betweenEnumFields", + "beginTypedef", + "endTypedef", + "betweenTypedefFields", + "afterSingleLineComment", + "afterMultiLineComment" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 7 + }, + "skipSingleLineTypes": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 8 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ExtendedEmptyLines" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "Config": { + "type": "object", + "properties": { + "extendsConfigPath": { + "type": "string", + "propertyOrder": 0 + }, + "defineCombinations": { + "items": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": "array", + "propertyOrder": 3 + }, + "defaultSeverity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + }, + "baseDefines": { + "items": { + "type": "string" + }, + "type": "array", + "propertyOrder": 2 + }, + "version": { + "minimum": 1, + "type": "integer", + "maximum": 1, + "propertyOrder": 7 + }, + "exclude": { + "propertyOrder": 6, + "$ref": "#/definitions/ExcludeConfig" + }, + "checks": { + "items": { + "anyOf": [ + { + "$ref": "#/definitions/AnonymousCheck" + }, + { + "$ref": "#/definitions/ArrayAccessCheck" + }, + { + "$ref": "#/definitions/ArrayLiteralCheck" + }, + { + "$ref": "#/definitions/AvoidInlineConditionalsCheck" + }, + { + "$ref": "#/definitions/AvoidStarImportCheck" + }, + { + "$ref": "#/definitions/CatchParameterNameCheck" + }, + { + "$ref": "#/definitions/ConditionalCompilationCheck" + }, + { + "$ref": "#/definitions/ConstantNameCheck" + }, + { + "$ref": "#/definitions/CyclomaticComplexityCheck" + }, + { + "$ref": "#/definitions/DefaultComesLastCheck" + }, + { + "$ref": "#/definitions/DynamicCheck" + }, + { + "$ref": "#/definitions/ERegLiteralCheck" + }, + { + "$ref": "#/definitions/EmptyBlockCheck" + }, + { + "$ref": "#/definitions/EmptyLinesCheck" + }, + { + "$ref": "#/definitions/EmptyPackageCheck" + }, + { + "$ref": "#/definitions/ExtendedEmptyLinesCheck" + }, + { + "$ref": "#/definitions/FileLengthCheck" + }, + { + "$ref": "#/definitions/HexadecimalLiteralCheck" + }, + { + "$ref": "#/definitions/HiddenFieldCheck" + }, + { + "$ref": "#/definitions/IndentationCheck" + }, + { + "$ref": "#/definitions/IndentationCharacterCheck" + }, + { + "$ref": "#/definitions/InnerAssignmentCheck" + }, + { + "$ref": "#/definitions/InterfaceCheck" + }, + { + "$ref": "#/definitions/LeftCurlyCheck" + }, + { + "$ref": "#/definitions/LineLengthCheck" + }, + { + "$ref": "#/definitions/ListenerNameCheck" + }, + { + "$ref": "#/definitions/LocalVariableNameCheck" + }, + { + "$ref": "#/definitions/MagicNumberCheck" + }, + { + "$ref": "#/definitions/MemberNameCheck" + }, + { + "$ref": "#/definitions/MethodCountCheck" + }, + { + "$ref": "#/definitions/MethodLengthCheck" + }, + { + "$ref": "#/definitions/MethodNameCheck" + }, + { + "$ref": "#/definitions/ModifierOrderCheck" + }, + { + "$ref": "#/definitions/MultipleStringLiteralsCheck" + }, + { + "$ref": "#/definitions/MultipleVariableDeclarationsCheck" + }, + { + "$ref": "#/definitions/NeedBracesCheck" + }, + { + "$ref": "#/definitions/NestedForDepthCheck" + }, + { + "$ref": "#/definitions/NestedIfDepthCheck" + }, + { + "$ref": "#/definitions/NestedTryDepthCheck" + }, + { + "$ref": "#/definitions/NullableParameterCheck" + }, + { + "$ref": "#/definitions/OperatorWhitespaceCheck" + }, + { + "$ref": "#/definitions/OperatorWrapCheck" + }, + { + "$ref": "#/definitions/ParameterNameCheck" + }, + { + "$ref": "#/definitions/ParameterNumberCheck" + }, + { + "$ref": "#/definitions/PublicAccessorCheck" + }, + { + "$ref": "#/definitions/RedundantModifierCheck" + }, + { + "$ref": "#/definitions/ReturnCheck" + }, + { + "$ref": "#/definitions/ReturnCountCheck" + }, + { + "$ref": "#/definitions/RightCurlyCheck" + }, + { + "$ref": "#/definitions/SeparatorWhitespaceCheck" + }, + { + "$ref": "#/definitions/SeparatorWrapCheck" + }, + { + "$ref": "#/definitions/SimplifyBooleanExpressionCheck" + }, + { + "$ref": "#/definitions/SimplifyBooleanReturnCheck" + }, + { + "$ref": "#/definitions/SpacingCheck" + }, + { + "$ref": "#/definitions/StringLiteralCheck" + }, + { + "$ref": "#/definitions/TODOCommentCheck" + }, + { + "$ref": "#/definitions/TabForAligningCheck" + }, + { + "$ref": "#/definitions/TraceCheck" + }, + { + "$ref": "#/definitions/TrailingWhitespaceCheck" + }, + { + "$ref": "#/definitions/TypeCheck" + }, + { + "$ref": "#/definitions/TypeNameCheck" + }, + { + "$ref": "#/definitions/UnnecessaryConstructorCheck" + }, + { + "$ref": "#/definitions/UnusedImportCheck" + }, + { + "$ref": "#/definitions/UnusedLocalVarCheck" + }, + { + "$ref": "#/definitions/VariableInitialisationCheck" + }, + { + "$ref": "#/definitions/WhitespaceAfterCheck" + }, + { + "$ref": "#/definitions/WhitespaceAroundCheck" + } + ] + }, + "type": "array", + "propertyOrder": 5 + }, + "numberOfCheckerThreads": { + "minimum": 1, + "type": "integer", + "maximum": 15, + "propertyOrder": 4 + } + }, + "additionalProperties": false + }, + "SpacingCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "spaceIfCondition": { + "enum": [ + "should", + "should_not", + "any" + ], + "type": "string", + "propertyOrder": 2 + }, + "spaceAroundBinop": { + "type": "boolean", + "propertyOrder": 0 + }, + "spaceForLoop": { + "enum": [ + "should", + "should_not", + "any" + ], + "type": "string", + "propertyOrder": 3 + }, + "ignoreRangeOperator": { + "type": "boolean", + "propertyOrder": 7 + }, + "spaceWhileLoop": { + "enum": [ + "should", + "should_not", + "any" + ], + "type": "string", + "propertyOrder": 4 + }, + "spaceCatch": { + "enum": [ + "should", + "should_not", + "any" + ], + "type": "string", + "propertyOrder": 6 + }, + "spaceSwitchCase": { + "enum": [ + "should", + "should_not", + "any" + ], + "type": "string", + "propertyOrder": 5 + }, + "noSpaceAroundUnop": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 8 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Spacing" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "AvoidStarImportCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "AvoidStarImport" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TrailingWhitespaceCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "TrailingWhitespace" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "FileLengthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "FileLength" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "NestedIfDepthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "NestedIfDepth" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TODOCommentCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "format": { + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "TODOComment" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "EmptyPackageCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "enforceEmptyPackage": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "EmptyPackage" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ConstantNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ConstantName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ParameterNumberCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + }, + "ignoreOverriddenMethods": { + "type": "boolean", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ParameterNumber" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ArrayLiteralCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ArrayLiteral" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TraceCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Trace" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "UnusedLocalVarCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "UnusedLocalVar" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "NeedBracesCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "allowSingleLineStatement": { + "type": "boolean", + "propertyOrder": 1 + }, + "tokens": { + "items": { + "enum": [ + "FUNCTION", + "FOR", + "IF", + "ELSE_IF", + "WHILE", + "DO_WHILE", + "CATCH" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "NeedBraces" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "LineLengthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "ignorePattern": { + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "LineLength" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "WhitespaceAroundCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "tokens": { + "items": { + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "WhitespaceAround" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "MethodLengthCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "countEmpty": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MethodLength" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "SeparatorWhitespaceCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "commaPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 1 + }, + "semicolonPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 2 + }, + "dotPolicy": { + "enum": [ + "before", + "after", + "around", + "none", + "ignore" + ], + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "SeparatorWhitespace" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ParameterNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ParameterName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "UnnecessaryConstructorCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "UnnecessaryConstructor" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "RedundantModifierCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "enforcePrivate": { + "type": "boolean", + "propertyOrder": 2 + }, + "enforcePublic": { + "type": "boolean", + "propertyOrder": 1 + }, + "enforcePublicPrivate": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "RedundantModifier" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "DefaultComesLastCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "DefaultComesLast" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TypeNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "TypeName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "SimplifyBooleanExpressionCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "SimplifyBooleanExpression" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ExcludeFilterList": { + "items": { + "type": "string" + }, + "type": "array" + }, + "MethodCountCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "maxPrivate": { + "type": "integer", + "propertyOrder": 1 + }, + "maxPublic": { + "type": "integer", + "propertyOrder": 2 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + }, + "maxTotal": { + "type": "integer", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "MethodCount" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "AnonymousCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Anonymous" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "CatchParameterNameCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "format": { + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "CatchParameterName" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "InnerAssignmentCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignoreReturnAssignments": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "InnerAssignment" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TypeCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignoreEnumAbstractValues": { + "type": "boolean", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Type" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "TabForAligningCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "ignorePattern": { + "type": "string", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "TabForAligning" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ModifierOrderCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "modifiers": { + "items": { + "enum": [ + "PUBLIC_PRIVATE", + "INLINE", + "STATIC", + "OVERRIDE", + "MACRO", + "DYNAMIC" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ModifierOrder" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "EmptyLinesCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "requireEmptyLineAfterPackage": { + "type": "boolean", + "propertyOrder": 3 + }, + "requireEmptyLineAfterInterface": { + "type": "boolean", + "propertyOrder": 5 + }, + "requireEmptyLineAfterAbstract": { + "type": "boolean", + "propertyOrder": 6 + }, + "allowEmptyLineAfterSingleLineComment": { + "type": "boolean", + "propertyOrder": 1 + }, + "max": { + "type": "integer", + "propertyOrder": 0 + }, + "requireEmptyLineAfterClass": { + "type": "boolean", + "propertyOrder": 4 + }, + "allowEmptyLineAfterMultiLineComment": { + "type": "boolean", + "propertyOrder": 2 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 7 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "EmptyLines" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "VariableInitialisationCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "VariableInitialisation" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "SeparatorWrapCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "SeparatorWrap" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "SimplifyBooleanReturnCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 0 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "SimplifyBooleanReturn" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "RightCurlyCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "tokens": { + "items": { + "enum": [ + "CLASS_DEF", + "ENUM_DEF", + "ABSTRACT_DEF", + "TYPEDEF_DEF", + "INTERFACE_DEF", + "OBJECT_DECL", + "FUNCTION", + "FOR", + "IF", + "WHILE", + "SWITCH", + "TRY", + "CATCH", + "REIFICATION", + "ARRAY_COMPREHENSION" + ], + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "option": { + "enum": [ + "same", + "alone", + "aloneorsingle" + ], + "type": "string", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "RightCurly" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ReturnCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "enforceReturnTypeForAnonymous": { + "type": "boolean", + "propertyOrder": 2 + }, + "allowEmptyReturn": { + "type": "boolean", + "propertyOrder": 0 + }, + "enforceReturnType": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 3 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "Return" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "ExcludeConfig": { + "type": "object", + "properties": { + "RightCurly": { + "propertyOrder": 52, + "$ref": "#/definitions/ExcludeFilterList" + }, + "path": { + "enum": [ + "RELATIVE_TO_PROJECT", + "RELATIVE_TO_SOURCE" + ], + "type": "string", + "propertyOrder": 0 + }, + "CatchParameterName": { + "propertyOrder": 9, + "$ref": "#/definitions/ExcludeFilterList" + }, + "VariableInitialisation": { + "propertyOrder": 68, + "$ref": "#/definitions/ExcludeFilterList" + }, + "HexadecimalLiteral": { + "propertyOrder": 21, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodLength": { + "propertyOrder": 34, + "$ref": "#/definitions/ExcludeFilterList" + }, + "HiddenField": { + "propertyOrder": 22, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodCount": { + "propertyOrder": 33, + "$ref": "#/definitions/ExcludeFilterList" + }, + "RedundantModifier": { + "propertyOrder": 49, + "$ref": "#/definitions/ExcludeFilterList" + }, + "PublicAccessor": { + "propertyOrder": 48, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedIfDepth": { + "propertyOrder": 41, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Interface": { + "propertyOrder": 26, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ArrayAccess": { + "propertyOrder": 5, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MagicNumber": { + "propertyOrder": 31, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Spacing": { + "propertyOrder": 57, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnusedImport": { + "propertyOrder": 66, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyPackage": { + "propertyOrder": 18, + "$ref": "#/definitions/ExcludeFilterList" + }, + "OperatorWhitespace": { + "propertyOrder": 44, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NeedBraces": { + "propertyOrder": 39, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ParameterName": { + "propertyOrder": 46, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LineLength": { + "propertyOrder": 28, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyLines": { + "propertyOrder": 17, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MultipleVariableDeclarations": { + "propertyOrder": 38, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ERegLiteral": { + "propertyOrder": 15, + "$ref": "#/definitions/ExcludeFilterList" + }, + "AvoidInlineConditionals": { + "propertyOrder": 7, + "$ref": "#/definitions/ExcludeFilterList" + }, + "WhitespaceAfter": { + "propertyOrder": 69, + "$ref": "#/definitions/ExcludeFilterList" + }, + "FileLength": { + "propertyOrder": 20, + "$ref": "#/definitions/ExcludeFilterList" + }, + "AvoidStarImport": { + "propertyOrder": 8, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ModifierOrder": { + "propertyOrder": 36, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ExtendedEmptyLines": { + "propertyOrder": 19, + "$ref": "#/definitions/ExcludeFilterList" + }, + "version": { + "minimum": 1, + "type": "integer", + "maximum": 1, + "propertyOrder": 2 + }, + "SeparatorWrap": { + "propertyOrder": 54, + "$ref": "#/definitions/ExcludeFilterList" + }, + "WhitespaceAround": { + "propertyOrder": 70, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ListenerName": { + "propertyOrder": 29, + "$ref": "#/definitions/ExcludeFilterList" + }, + "": { + "propertyOrder": 3, + "$ref": "#/definitions/ExcludeFilterList" + }, + "CyclomaticComplexity": { + "propertyOrder": 12, + "$ref": "#/definitions/ExcludeFilterList" + }, + "all": { + "propertyOrder": 1, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SimplifyBooleanExpression": { + "propertyOrder": 55, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SeparatorWhitespace": { + "propertyOrder": 53, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TrailingWhitespace": { + "propertyOrder": 62, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Dynamic": { + "propertyOrder": 14, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LeftCurly": { + "propertyOrder": 27, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ParameterNumber": { + "propertyOrder": 47, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MethodName": { + "propertyOrder": 35, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnusedLocalVar": { + "propertyOrder": 67, + "$ref": "#/definitions/ExcludeFilterList" + }, + "IndentationCharacter": { + "propertyOrder": 24, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ArrayLiteral": { + "propertyOrder": 6, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MemberName": { + "propertyOrder": 32, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TypeName": { + "propertyOrder": 64, + "$ref": "#/definitions/ExcludeFilterList" + }, + "InnerAssignment": { + "propertyOrder": 25, + "$ref": "#/definitions/ExcludeFilterList" + }, + "UnnecessaryConstructor": { + "propertyOrder": 65, + "$ref": "#/definitions/ExcludeFilterList" + }, + "MultipleStringLiterals": { + "propertyOrder": 37, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Anonymous": { + "propertyOrder": 4, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedTryDepth": { + "propertyOrder": 42, + "$ref": "#/definitions/ExcludeFilterList" + }, + "SimplifyBooleanReturn": { + "propertyOrder": 56, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TODOComment": { + "propertyOrder": 59, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ConstantName": { + "propertyOrder": 11, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Trace": { + "propertyOrder": 61, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NullableParameter": { + "propertyOrder": 43, + "$ref": "#/definitions/ExcludeFilterList" + }, + "TabForAligning": { + "propertyOrder": 60, + "$ref": "#/definitions/ExcludeFilterList" + }, + "EmptyBlock": { + "propertyOrder": 16, + "$ref": "#/definitions/ExcludeFilterList" + }, + "NestedForDepth": { + "propertyOrder": 40, + "$ref": "#/definitions/ExcludeFilterList" + }, + "StringLiteral": { + "propertyOrder": 58, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ConditionalCompilation": { + "propertyOrder": 10, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Type": { + "propertyOrder": 63, + "$ref": "#/definitions/ExcludeFilterList" + }, + "OperatorWrap": { + "propertyOrder": 45, + "$ref": "#/definitions/ExcludeFilterList" + }, + "ReturnCount": { + "propertyOrder": 51, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Indentation": { + "propertyOrder": 23, + "$ref": "#/definitions/ExcludeFilterList" + }, + "DefaultComesLast": { + "propertyOrder": 13, + "$ref": "#/definitions/ExcludeFilterList" + }, + "Return": { + "propertyOrder": 50, + "$ref": "#/definitions/ExcludeFilterList" + }, + "LocalVariableName": { + "propertyOrder": 30, + "$ref": "#/definitions/ExcludeFilterList" + } + }, + "additionalProperties": false + }, + "ConditionalCompilationCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "policy": { + "enum": [ + "startOfLine", + "aligned" + ], + "type": "string", + "propertyOrder": 0 + }, + "allowSingleline": { + "type": "boolean", + "propertyOrder": 1 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 2 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "ConditionalCompilation" + ], + "type": "string" + } + }, + "additionalProperties": false + }, + "WhitespaceAfterCheck": { + "type": "object", + "properties": { + "props": { + "type": "object", + "properties": { + "tokens": { + "items": { + "type": "string" + }, + "type": "array", + "propertyOrder": 0 + }, + "severity": { + "enum": [ + "INFO", + "WARNING", + "ERROR", + "IGNORE" + ], + "type": "string", + "propertyOrder": 1 + } + }, + "additionalProperties": false + }, + "type": { + "enum": [ + "WhitespaceAfter" + ], + "type": "string" + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/schema/CheckstyleSchemaGenerator.hx b/schema/CheckstyleSchemaGenerator.hx new file mode 100644 index 00000000..dd13f22b --- /dev/null +++ b/schema/CheckstyleSchemaGenerator.hx @@ -0,0 +1,145 @@ +#if macro +import haxe.DynamicAccess; +import haxe.macro.Context; +import haxe.macro.Expr; +import haxe.macro.Type; +import sys.FileSystem; +import haxe.io.Path; +import haxe.ds.ArraySort; + +using StringTools; + +typedef CheckName = { + var name:String; + var path:String; +} +#end + +class CheckstyleSchemaGenerator { + + macro public static function generate(type:String, id:String):Expr { + return JsonSchemaGenerator.generateWithCallback(type, id, checkstyleFieldsCallback); + } + + #if macro + static function checkstyleFieldsCallback(fields:Array, name:String, pos:Position, refs:DynamicAccess):Void { + switch (name) { + case "ExcludeConfig": + var checkList:Array = collectAllChecks(Path.join (["src", "checkstyle", "checks"])); + sortStrings(checkList); + var order:Int = fields.length; + for (check in checkList) { + var filterListType = Context.getType("checkstyle.config.ExcludeConfig.ExcludeFilterList"); + fields.push({ + field:check.name, + expr:JsonSchemaGenerator.genSchema(filterListType, "ExcludeFilterList", pos, null, refs, order++, null) + }); + } + case "Config.checks": + fields.pop(); + fields.pop(); + refs.remove("CheckConfig"); + var checkExprs:Array = []; + var checkList:Array = collectAllChecks(Path.join (["src", "checkstyle", "checks"])); + sortStrings(checkList); + for (check in checkList) { + if (check.name == "") continue; + var type:String = check.path.substr (4); + checkExprs.push(genCheckSchema(Context.getType(type), check.name, pos, null, refs, -1)); + } + fields.push({field: "type", expr: macro "array"}); + var anyFields:Array = []; + anyFields.push({field: "anyOf", expr: macro $a{checkExprs}}); + fields.push({field: "items", expr: SchemaUtils.makeObjectDecl(anyFields, -1, pos)}); + case "Config.numberOfCheckerThreads": + fields.push({field: "minimum", expr: macro 1}); + fields.push({field: "maximum", expr: macro 15}); + case "Config.version": + fields.push({field: "minimum", expr: macro 1}); + fields.push({field: "maximum", expr: macro 1}); + case "ExcludeConfig.version": + fields.push({field: "minimum", expr: macro 1}); + fields.push({field: "maximum", expr: macro 1}); + default: + } + } + + static inline function sortStrings(texts:Array) { + ArraySort.sort(texts, function(a:CheckName, b:CheckName):Int { + if (a.name > b.name) return 1; + if (a.name < b.name) return -1; + return 0; + }); + } + + static function collectAllChecks(path:String):Array { + var items:Array = FileSystem.readDirectory(path); + var checks:Array = []; + for (item in items) { + if (item == "." || item == "..") continue; + var fileName = Path.join([path, item]); + if (FileSystem.isDirectory(fileName)) { + checks = checks.concat(collectAllChecks(fileName)); + continue; + } + if (!StringTools.endsWith(item, "Check.hx")) { + continue; + } + var name = item.substr(0, item.length - 3); + if (name.length <= 0) { + continue; + } + var fullPath:String = ~/[\/\\]/g.replace(Path.join([path, name]), "."); + name = name.substr(0, name.length - 5); + checks.push({name:name, path:fullPath}); + } + return checks; + } + + public static function genCheckSchema(type:Type, typeName:String, pos:Position, structInfo:Null, refs:DynamicAccess, order:Int):Expr { + switch (type) { + case TInst(_.get() => cl, params): + switch [cl, params] { + case [{name:name, fields:fields}, []]: + if (!refs.exists(name)) { + refs[name] = null; + var classFields:Array = []; + var fieldOrder:Int = 0; + for (field in fields.get()) { + switch (field.kind) { + case FVar(_): + if (field.isPublic) { + classFields.push ({ + field: field.name, + expr: JsonSchemaGenerator.genSchema(field.type, typeName + "." + name, pos, null, refs, fieldOrder, null) + }); + fieldOrder++; + } + default: + } + } + classFields.push({ + field: "severity", + expr: JsonSchemaGenerator.genSchema(Context.getType("checkstyle.SeverityLevel"), typeName + ".severity", pos, null, refs, fieldOrder, null) + }); + + var props = SchemaUtils.makeObject(SchemaUtils.makeObjectDecl(classFields, -1, pos), null, [], -1, pos); + var checkName:Array = [macro '$typeName']; + var typeExpr:Expr = macro $a{checkName}; + var type = SchemaUtils.makeEnum(typeExpr, -1, pos); + var checkFields:Array = [ + {field: "type", expr: type}, + {field: "props", expr: props}, + ]; + var classExpr:Expr = SchemaUtils.makeObject(SchemaUtils.makeObjectDecl(checkFields, -1, pos), null, [], -1, pos); + refs[name] = classExpr; + } + return SchemaUtils.makeObjectDecl([{ field: "@$__hx__$ref", expr: macro '#/definitions/${name}'}], order, pos); + default: + } + default: + } + throw new Error("Cannot generate Json schema for type " + type, pos); // + type.toString(), pos); + } + #end +} \ No newline at end of file diff --git a/schema/JsonSchemaGenerator.hx b/schema/JsonSchemaGenerator.hx new file mode 100644 index 00000000..7903ef72 --- /dev/null +++ b/schema/JsonSchemaGenerator.hx @@ -0,0 +1,156 @@ +#if macro +import haxe.DynamicAccess; +import haxe.macro.Context; +import haxe.macro.Expr; +import haxe.macro.Type; + +using haxe.macro.Tools; +using StringTools; + +typedef ExtendedFieldsCB = Array -> String -> Position -> DynamicAccess -> Void; +#end + +// adapted from https://github.com/nadako/haxe-type-to-json-schema +class JsonSchemaGenerator { + + macro public static function generate(type:String, id:String):Expr { + return generateWithCallback(type, id, null); + } + + #if macro + public static function generateWithCallback(type:String, id:String, extendedFieldsCB:ExtendedFieldsCB):Expr { + var refs = new DynamicAccess(); + + var main:Expr = genSchema(Context.getType(type), type, Context.currentPos(), null, refs, -1, extendedFieldsCB); + + var refList:Array = []; + for (name in refs.keys()) { + refList.push({field:name, expr:refs.get(name)}); + } + + var definitions:Expr = SchemaUtils.makeObjectDecl(refList, -1, Context.currentPos()); + switch (main.expr) { + case EObjectDecl(fields): + fields.push ({field: "definitions", expr:definitions}); + fields.push ({field: "@$__hx__$schema", expr: macro "http://json-schema.org/schema#"}); + if (id != null) { + fields.push ({field: "id", expr: macro '$id'}); + } + default: + } + return main; + } + + static function getAbstractEnumValues(typePath:Expr):Expr { + // trace (typePath); + // Get the type from a given expression converted to string. + // This will work for identifiers and field access which is what we need, + // it will also consider local imports. If expression is not a valid type path or type is not found, + // compiler will give a error here. + var type = Context.getType(typePath.toString()); + + // Switch on the type and check if it's an abstract with @:enum metadata + // switch (type.follow(false)) { + switch (type) { + case TAbstract(_.get() => ab, _) if (ab.meta.has(":enum")): + // @:enum abstract values are actually static fields of the abstract implementation class, + // marked with @:enum and @:impl metadata. We generate an array of expressions that access those fields. + // Note that this is a bit of implementation detail, so it can change in future Haxe versions, but it's been + // stable so far. + var valueExprs = []; + for (field in ab.impl.get().statics.get()) { + if (field.meta.has(":enum") && field.meta.has(":impl")) { + var fieldName = field.name; + valueExprs.push(macro $typePath.$fieldName); + } + } + // Return collected expressions as an array declaration. + return macro $a{valueExprs}; + default: + // The given type is not an abstract, or doesn't have @:enum metadata, show a nice error message. + throw new Error(type.toString() + " should be @:enum abstract", typePath.pos); + } + } + + public static function genSchema(type:Type, + typeName:String, + pos:Position, + structInfo:Null, + refs:DynamicAccess, order:Int, + extendCB:ExtendedFieldsCB):Expr { + switch (type) { + case TType(_.get() => dt, params): + return switch [dt, params] { + case [{pack: [], name: "Null"}, [realT]]: + genSchema(realT, typeName, pos, null, refs, order, extendCB); + default: + if (!refs.exists(dt.name)) { + refs[dt.name] = null; + var schema = genSchema(dt.type.applyTypeParameters(dt.params, params), + dt.name, dt.pos, {name: dt.name, doc: dt.doc}, refs, -1, extendCB); + refs[dt.name] = schema; + } + return SchemaUtils.makeObjectDecl([{ field: "@$__hx__$ref", expr: macro '#/definitions/${dt.name}'}], order, pos); + } + + case TInst(_.get() => cl, params): + switch [cl, params] { + case [{pack: [], name: "String"}, []]: + return SchemaUtils.makeObjectDecl([{ field: "type", expr: macro "string"}], order, pos); + case [{pack: [], name: "Array"}, [elemType]]: + var fields:Array = [ + {field: "type", expr: macro "array"}, + {field: "items", expr: genSchema(elemType, typeName, pos, null, refs, -1, extendCB)} + ]; + if (extendCB != null) extendCB(fields, typeName, pos, refs); + return SchemaUtils.makeObjectDecl(fields, order, pos); + default: + } + + case TAbstract(_.get() => ab, params): + switch [ab, params] { + case [{pack: [], name: "Int"}, []]: + var fields:Array = [{field: "type", expr: macro "integer"}]; + if (extendCB != null) extendCB(fields, typeName, pos, refs); + return SchemaUtils.makeObjectDecl(fields, order, pos); + case [{pack: [], name: "Float"}, []]: + return SchemaUtils.makeObjectDecl([{ field: "type", expr: macro "number"}], order, pos); + case [{pack: [], name: "Bool"}, []]: + return SchemaUtils.makeObjectDecl([{ field: "type", expr: macro "boolean"}], order, pos); + case [{pack: [], name: "Any"}, []]: + return SchemaUtils.makeObjectDecl([{ field: "type", expr: macro "object"}], order, pos); + default: + if (ab.meta.has(":enum")) { + var pack:Array = ab.module.split("."); + if (pack[pack.length - 1] != ab.name) pack.push(ab.name); + return SchemaUtils.makeEnum(getAbstractEnumValues(macro $p{pack}), order, pos); + } + } + + case TAnonymous(_.get() => anon): + var required = []; + // sort by declaration position + anon.fields.sort(function(a, b) return a.pos.getInfos().min - b.pos.getInfos().min); + var props:Array = []; + for (i in 0...anon.fields.length) { + var f = anon.fields[i]; + var doc:StructInfo = null; + if (f.doc != null) { + doc = {name:f.name, doc:f.doc.trim()}; + } + props.push ({field: f.name, expr: genSchema(f.type, typeName + "." + f.name, f.pos, doc, refs, i, extendCB)}); + if (!f.meta.has(":optional")) { + required.push(f.name); + } + } + if (extendCB != null) { + extendCB(props, typeName, pos, refs); + } + return SchemaUtils.makeObject({pos: pos, expr:EObjectDecl(props)}, structInfo, required, order, pos); + + default: + } + throw new Error("Cannot generate Json schema for type " + type, pos); // + type.toString(), pos); + } + #end +} \ No newline at end of file diff --git a/schema/ObjectDeclField.hx b/schema/ObjectDeclField.hx new file mode 100644 index 00000000..8f1ddd7d --- /dev/null +++ b/schema/ObjectDeclField.hx @@ -0,0 +1,13 @@ +#if macro +import haxe.macro.Expr; + +#if (haxe_ver < 4.0) +typedef ObjectDeclField = { + var field:String; + var expr:Expr; +} +#else +typedef ObjectDeclField = haxe.macro.ObjectField; +#end + +#end \ No newline at end of file diff --git a/schema/SchemaGenerator.hx b/schema/SchemaGenerator.hx new file mode 100644 index 00000000..f229cdf3 --- /dev/null +++ b/schema/SchemaGenerator.hx @@ -0,0 +1,18 @@ +import haxe.Json; +import haxe.io.Path; +import sys.io.File; + +class SchemaGenerator { + + public static function main() { + #if (haxe_ver < 4.0) + var exludeConfig = CheckstyleSchemaGenerator.generate("checkstyle.config.ExcludeConfig", + "https://raw.githubusercontent.com/HaxeCheckstyle/haxe-checkstyle/dev/resources/checkstyle-excludes-schema.json"); + File.saveContent(Path.join(["resources", "checkstyle-excludes-schema.json"]), Json.stringify(exludeConfig, " ")); + + var config = CheckstyleSchemaGenerator.generate("checkstyle.config.Config", + "https://raw.githubusercontent.com/HaxeCheckstyle/haxe-checkstyle/dev/resources/checkstyle-schema.json"); + File.saveContent(Path.join(["resources", "checkstyle-schema.json"]), Json.stringify(config, " ")); + #end + } +} \ No newline at end of file diff --git a/schema/SchemaUtils.hx b/schema/SchemaUtils.hx new file mode 100644 index 00000000..e8a4216e --- /dev/null +++ b/schema/SchemaUtils.hx @@ -0,0 +1,35 @@ +#if macro +import haxe.macro.Expr; + +class SchemaUtils { + + public static function makeObjectDecl(fields:Array, order:Int, pos:Position):Expr { + if (order >= 0) fields.push({field: "propertyOrder", expr: macro $v{order}}); + return {pos: pos, expr: EObjectDecl(fields)}; + } + + public static function makeObject(props:Expr, structInfo:Null, required:Array, order:Int, pos:Position):Expr { + var fields:Array = [ + {field: "type", expr: macro "object"}, + {field: "properties", expr: props}, + {field: "additionalProperties", expr: macro false} + ]; + + if (structInfo != null && structInfo.doc != null) { + fields.push({field: "description", expr: macro structInfo.doc.trim()}); + } + if (required.length > 0) { + var exprs:Array = [for(req in required) macro $v{req}]; + fields.push({field: "required", expr: macro $a{exprs}}); + } + return makeObjectDecl(fields, order, pos); + } + + public static function makeEnum(enumList:Expr, order:Int, pos:Position):Expr { + return makeObjectDecl([ + {field: "type", expr: macro "string"}, + {field: "enum", expr: enumList} + ], order, pos); + } +} +#end \ No newline at end of file diff --git a/schema/StructInfo.hx b/schema/StructInfo.hx new file mode 100644 index 00000000..b3710145 --- /dev/null +++ b/schema/StructInfo.hx @@ -0,0 +1,4 @@ +typedef StructInfo = { + name:String, + doc:String, +} \ No newline at end of file diff --git a/src/checkstyle/config/ConfigParser.hx b/src/checkstyle/config/ConfigParser.hx index d08f8691..21e0dc9a 100644 --- a/src/checkstyle/config/ConfigParser.hx +++ b/src/checkstyle/config/ConfigParser.hx @@ -48,7 +48,7 @@ class ConfigParser { function getAbsoluteConfigPath(path:String, baseFolder:String):String { if (path == null) return null; if (Path.isAbsolute(path)) return path; - return Path.join ([baseFolder, path]); + return Path.join([baseFolder, path]); } public function parseAndValidateConfig(config:Config, rootFolder:String) { diff --git a/src/checkstyle/config/ExcludeConfig.hx b/src/checkstyle/config/ExcludeConfig.hx index 222e77eb..ad56e4f6 100644 --- a/src/checkstyle/config/ExcludeConfig.hx +++ b/src/checkstyle/config/ExcludeConfig.hx @@ -2,6 +2,8 @@ package checkstyle.config; typedef ExcludeConfig = { @:optional var path:ExcludePath; - @:optional var all:Array; + @:optional var all:ExcludeFilterList; @:optional var version:Int; -} \ No newline at end of file +} + +typedef ExcludeFilterList = Array; \ No newline at end of file