|
| 1 | +--- |
| 2 | +description: "NiFi Hub coding conventions and build instructions" |
| 3 | +alwaysApply: true |
| 4 | +--- |
| 5 | + |
| 6 | +## Project Overview |
| 7 | + |
| 8 | +NiFi Hub is a repository of independently-versioned Apache NiFi extension bundles and versioned flow definitions. |
| 9 | +All Java code uses package `com.snowflake.nifihub`. |
| 10 | + |
| 11 | +## Building |
| 12 | + |
| 13 | +NiFi Hub uses Maven. Never use `javac` directly. Each bundle builds independently: |
| 14 | + |
| 15 | +```bash |
| 16 | +./mvnw clean verify -Pcontrib-check -f <bundle-path>/pom.xml |
| 17 | +``` |
| 18 | + |
| 19 | +The root POM has no `<modules>` block. Do NOT run `mvn install` from root expecting to build all bundles. |
| 20 | + |
| 21 | +## Code Style |
| 22 | + |
| 23 | +1. Mark all possible variables `final` (method arguments, local variables, member variables, catch variables). |
| 24 | +2. No star imports. Import each class individually. |
| 25 | +3. No underscores in class names, variables, or filenames. |
| 26 | +4. Line width: up to 200 characters. |
| 27 | +5. 4-space indentation, no tabs. |
| 28 | +6. Use SLF4J loggers, never `System.out.println`. |
| 29 | +7. Use `.formatted()` for string formatting instead of `+` concatenation. |
| 30 | +8. Include Apache 2.0 license header in all source files. |
| 31 | +9. Avoid creating trivial 1-2 line private methods called only once. |
| 32 | +10. Private/helper methods should not appear before the first public/protected method that calls them. |
| 33 | + |
| 34 | +## Testing |
| 35 | + |
| 36 | +- Unit tests use `nifi-mock` framework via `TestRunner` from `TestRunners.newTestRunner()`. |
| 37 | +- Test classes are named `Test<ClassName>.java`. |
| 38 | +- Code coverage must be >= 80%. |
| 39 | +- Never use `assertDoesNotThrow`. Just call the method directly. |
| 40 | +- Never add `// Given`, `// When`, `// Then` comments. |
| 41 | +- Use JUnit assertions (never the `assert` keyword). |
| 42 | + |
| 43 | +## Package Naming |
| 44 | + |
| 45 | +Java packages follow: `com.snowflake.nifihub.<category>.<bundlename>` |
| 46 | + |
| 47 | +Example: `com.snowflake.nifihub.example` for the example bundle. |
| 48 | + |
| 49 | +## Bundle Structure |
| 50 | + |
| 51 | +Every bundle follows this structure: |
| 52 | +``` |
| 53 | +nifi-<name>-bundle/ |
| 54 | +├── pom.xml (packaging: pom, parent: nifihub-parent) |
| 55 | +├── SKILL.md (agent-readable bundle documentation) |
| 56 | +├── nifi-<name>-processors/ |
| 57 | +│ ├── pom.xml (packaging: jar) |
| 58 | +│ └── src/ |
| 59 | +└── nifi-<name>-nar/ |
| 60 | + └── pom.xml (packaging: nar) |
| 61 | +``` |
| 62 | + |
| 63 | +## Ending Conditions |
| 64 | + |
| 65 | +Before considering a task complete: |
| 66 | +1. `./mvnw clean verify -Pcontrib-check -f <bundle>/pom.xml` passes |
| 67 | +2. Code coverage >= 80% |
| 68 | +3. SKILL.md is present and up-to-date |
| 69 | +4. All code follows the style rules above |
0 commit comments