no-java-keywords
Rule Details
The CAP Java code generation bases its class and method names on CDS entities. If reserved Java keywords are used as CDS identifiers, the code generation or compilation may fail. This rule helps identify such identifiers early on and suggest to use the @cds.java.name
annotation.
Examples
✅ Correct example
In the following example, use of the reserved Java keyword as identifiers is fixed via the @cds.java.name
annotation, so the rule doesn't raise any warnings:
cds
namespace sap.capire.bookshop;
entity Books {
key ID : Integer;
@cds.java.name: 'isNew'
new : Boolean;
};
1
2
3
4
5
6
7
2
3
4
5
6
7
❌ Incorrect example
In the next example, the reserved SQL keyword new
is used as an element name, so the rule will raise a warning:
cds
namespace sap.capire.bookshop;
entity Books {
key ID : Integer;
new : Boolean;
};
1
2
3
4
5
6
2
3
4
5
6
Version
This rule was introduced in @sap/eslint-plugin-cds 3.2.0
.