docs/community/content/involved/conduct/code.en.md
+++ title = "Code of Conduct" weight = 2 chapter = true +++
The following code of conduct is based on full compliance with the Apache Software Foundation Code of Conduct.
./mvnw clean install -B -T1C -Pcheck../mvnw spotless:apply -Pcheck to format code.getter /setter methods, unit tests need full coverage.src/resources/idea/code-style.xml to maintain code style consistency.src/resources/idea/inspections.xml to detect potential code issues.arguments abbreviated as args;parameters abbreviated as params;environment abbreviated as env;properties abbreviated as props;configuration abbreviated as config.result;each to name loop variables in loops;entry instead of each in maps;ex;ignored.result, each, entry.xxUtils.Spinal Case naming (a special Snake Case that uses - to separate words).equals and == conditional expressions, constants on the left, variables on the right; in conditional expressions like greater than or less than, variables on the left, constants on the right.this modifier except for assignment statements where constructor parameters have the same name as global variables.final except for abstract classes used for inheritance.null.Optional; pass plain values (nullable when needed).LinkedList first, only use ArrayList when you need to get element values from the collection by index.ArrayList, HashMap must specify initial collection size to avoid expansion.if (null == param) {} else {}.@HighFrequencyInvocation annotation reasonably to focus on performance optimization of key methods.
@HighFrequencyInvocation annotation:
canBeCached attribute is true, it indicates the target is a reusable cache resource, for example: database connections.@HighFrequencyInvocation must strictly guarantee code performance, the following are prohibited items in marked code segments:
+;get(int index) method.System.out, log, etc. is not allowed, assertions must be used for verification.assert prefix for all test method names.Plugins.getMemberAccessor() and limit reflection to Field access only.getter /setter methods, unit tests need full coverage.assert<MethodName> without extra suffixes, and prefer isolating one public production method per dedicated test method; when practical, keep test method ordering aligned with the corresponding production methods."{0}" as the display-name template.not, containsString assertions.Assertions, hamcrest CoreMatchers and MatcherAssert related can use static import.assertTrue and assertFalse;assertNull and assertNotNull;assertThat(actual, is(expected)) instead of assertEquals;assertThat(..., isA(...)) instead of instanceOf;assertSame / assertNotSame; use instead of assertThat(actual, is(expected)) or assertThat(actual, not(expected));is(), not() for precise and readable assertions.@Test do not need JAVADOC.mock should follow the following specifications:
mock should be used;mock should be used.AutoMockExtension and StaticMockSettings provided by the testing framework for automatic resource release; if using Mockito's mockStatic and mockConstruction methods, must be paired with try-with-resource or closed in cleanup methods to avoid leaks.times(1) parameter, the single-parameter method of verify is sufficient.RETURNS_DEEP_STUBS instead of layering intermediate mocks.foo_/bar_) to clearly identify their test purposePropertiesBuilder simplify Properties building.The G4 grammar files and SQLVisitor implementation classes involved in the SQL parsing module need to be marked with differential code according to the following database relationships. When database A does not provide corresponding database drivers and protocols, but directly uses database B's drivers and protocols, database A can be considered a branch database of database B.
Usually branch databases will directly use the SQL parsing logic of the trunk database, but to adapt to the unique syntax of branch databases, some branch databases will copy from the trunk database and maintain their own SQL parsing logic. At this time, for the unique syntax of branch databases, comments need to be used for marking, and other parts need to be consistent with the implementation of the trunk database;
| Trunk Database | Branch Database |
|---|---|
| MySQL | MariaDB, Doris |
| PostgreSQL | - |
| openGauss | - |
| Oracle | - |
| SQLServer | - |
| ClickHouse | - |
| Hive | - |
| Presto | - |
| SQL92 | - |
Differential code marking syntax, replace {DatabaseType} with the database type uppercase name when adding, for example: DORIS.
// {DatabaseType} ADDED BEGIN and // {DatabaseType} ADDED END;// {DatabaseType} CHANGED BEGIN and // {DatabaseType} CHANGED END.underscore separation. DataType and Symbol rule names end with underscore. Rules with the same name as ANTLR built-in variables or keywords add underscore at the end for distinction.fragment, fragment defined rules need to be declared after the rules they serve.Keyword.g4, each database can have its own specific rule definitions. For example: MySQLKeyword.g4.colon before starting to write the rule, semicolon on a separate line and maintain the same indentation as the previous line.5 branches, each branch should be on a separate line.database name + statement type name + Statement. For example: MySQLDQLStatement.g4..yml.trigger method-execution operation. For example: nightly-check.yml. pull_request triggered tasks omit the trigger method, for example: check.yml.name attribute naming in Workflow files should be consistent with the file name, words separated by - with spaces on both sides of the separator, and the first letter of each word capitalized. For example: Nightly - Check.name attribute under Step should describe the function of the step, with the first letter of each word capitalized and prepositions in lowercase. For example: Build Project with Maven.job attribute naming in Workflow must be unique within the Workflow.matrix, you must add job parallelism limit of 20. For example: max-parallel: 20.timeout-minutes: 10.