comment stringlengths 1 45k | method_body stringlengths 23 281k | target_code stringlengths 0 5.16k | method_body_after stringlengths 12 281k | context_before stringlengths 8 543k | context_after stringlengths 8 543k |
|---|---|---|---|---|---|
fixed. | Mono<DecryptResult> decryptAsync(EncryptionAlgorithm algorithm, byte[] cipherText, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Context context, JsonWebKey key) {
throw new UnsupportedOperationException("Decrypt operaiton is not supported for EC key");
} | throw new UnsupportedOperationException("Decrypt operaiton is not supported for EC key"); | Mono<DecryptResult> decryptAsync(EncryptionAlgorithm algorithm, byte[] cipherText, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Context context, JsonWebKey key) {
throw new UnsupportedOperationException("Decrypt operation is not supported for EC key");
} | class EcKeyCryptographyClient {
private KeyPair keyPair;
private CryptographyServiceClient serviceClient;
private Provider provider;
/**
* Creates a EcKeyCryptographyClient that uses {@code service} to service requests
*
* @param serviceClient the client to use for service side cryptography operations.
*/
EcKeyCryptogr... | class EcKeyCryptographyClient extends LocalKeyCryptographyClient {
private KeyPair keyPair;
private CryptographyServiceClient serviceClient;
private Provider provider;
/**
* Creates a EcKeyCryptographyClient that uses {@code service} to service requests
*
* @param serviceClient the client to use for service side crypto... |
updated. | public KeyWrapResult wrapKey(KeyWrapAlgorithm algorithm, byte[] key) {
return client.wrapKey(algorithm, key, Context.NONE).block();
} | return client.wrapKey(algorithm, key, Context.NONE).block(); | public KeyWrapResult wrapKey(KeyWrapAlgorithm algorithm, byte[] key) {
return wrapKey(algorithm, key, Context.NONE);
} | class CryptographyClient {
private CryptographyAsyncClient client;
/**
* Creates a KeyClient that uses {@code pipeline} to service requests
*
* @param client The {@link CryptographyAsyncClient} that the client routes its request through.
*/
CryptographyClient(CryptographyAsyncClient client) {
this.client = client;
}
/*... | class CryptographyClient {
private final CryptographyAsyncClient client;
/**
* Creates a KeyClient that uses {@code pipeline} to service requests
*
* @param client The {@link CryptographyAsyncClient} that the client routes its request through.
*/
CryptographyClient(CryptographyAsyncClient client) {
this.client = client... |
That works too. | private void unpackAndValidateId(String keyId) {
if (keyId != null && keyId.length() > 0) {
try {
URL url = new URL(keyId);
String[] tokens = url.getPath().split("/");
String endpoint = url.getProtocol() + ":
String keyName = (tokens.length >= 3 ? tokens[2] : null);
version = (tokens.length >= 4 ? tokens[3] : null);
if... | if (keyId != null && keyId.length() > 0) { | private void unpackAndValidateId(String keyId) {
if (ImplUtils.isNullOrEmpty(keyId)) {
throw new IllegalArgumentException("Key Id is invalid");
}
try {
URL url = new URL(keyId);
String[] tokens = url.getPath().split("/");
String endpoint = url.getProtocol() + ":
String keyName = (tokens.length >= 3 ? tokens[2] : null);... | class CryptographyAsyncClient {
private JsonWebKey key;
private CryptographyService service;
private String version;
private EcKeyCryptographyClient ecKeyCryptographyClient;
private RsaKeyCryptographyClient rsaKeyCryptographyClient;
private CryptographyServiceClient cryptographyServiceClient;
private SymmetricKeyCrypto... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
private JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new Clien... |
because the return type is void. | Mono<EncryptResult> encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, Context context, byte[] iv, byte[] authenticationData) {
Objects.requireNonNull(algorithm);
boolean keyAvailableLocally = ensureValidKeyAvailable();
if(!keyAvailableLocally) {
return cryptographyServiceClient.encrypt(algorithm, plaintext, cont... | throw new UnsupportedOperationException(String.format("Encrypt Async is not allowed for Key Type: %s", key.kty().toString())); | Mono<EncryptResult> encrypt(EncryptionAlgorithm algorithm, byte[] plaintext, Context context, byte[] iv, byte[] authenticationData) {
Objects.requireNonNull(algorithm, "Encryption algorithm cannot be null.");
Objects.requireNonNull(plaintext, "Plain text content to be encrypted cannot be null.");
boolean keyAvailableLo... | class CryptographyAsyncClient {
private JsonWebKey key;
private CryptographyService service;
private String version;
private EcKeyCryptographyClient ecKeyCryptographyClient;
private RsaKeyCryptographyClient rsaKeyCryptographyClient;
private CryptographyServiceClient cryptographyServiceClient;
private SymmetricKeyCrypto... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
private JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new Clien... |
If ANNOTATION is a child of MODIFIER use getFirstToken, it does what this for loop is doing. | private boolean hasServiceClientAnnotation(DetailAST classDefToken) {
final DetailAST modifiersToken = classDefToken.findFirstToken(TokenTypes.MODIFIERS);
for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) {
if (ast.getType() != TokenTypes.ANNOTATION) {
continue;
}
final Detai... | for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { | private boolean hasServiceClientAnnotation(DetailAST classDefToken) {
final DetailAST modifiersToken = classDefToken.findFirstToken(TokenTypes.MODIFIERS);
for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) {
if (ast.getType() != TokenTypes.ANNOTATION) {
continue;
}
final Detai... | class is annotated with @ServiceClient, false otherwise.
*/ | class is annotated with @ServiceClient, false otherwise.
*/ |
This check may not trigger when it should since async class can false-positive into the check above. I think we should change this a bit by having: ``` Java if (async name) { async checks; } else if (sync name) { sync checks; } else { naming error } | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient.", className));
}
if (!isAsy... | if (className.endsWith(ASYNC_CLIENT) && !isAsync) { | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className));
}
if (!isAsy... | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ |
Error message says `class must be named AsyncClient` but condition only check if name ends with this string. So, a name like `thisIsMySuperMethodAsyncClient` would be valid right? If yes, update the error message to say that `class name must end with this string. | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient.", className));
}
if (!isAsy... | if (isAsync && !className.endsWith(ASYNC_CLIENT)) { | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className));
}
if (!isAsy... | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ |
Do we want to make this if statements `else if` statements? Do we need to check all condition even after we find one as true? | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient.", className));
}
if (!isAsy... | if (className.endsWith(CLIENT) && !className.endsWith(ASYNC_CLIENT) && isAsync) { | private void checkServiceClientNaming(DetailAST classDefToken) {
final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText();
if (isAsync && !className.endsWith(ASYNC_CLIENT)) {
log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className));
}
if (!isAsy... | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ | class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client.
*
* @param classDefToken the CLASS_DEF AST node
*/ |
If the class does not have `@ServiceClient` annotation, is it possible to terminate this custom checkstyle evaluation i.e. no more calls to `visitToken()`? If that's possible, you could simplify the other switch cases by not having to check `if (!hasServiceClientAnnotation)` | public void visitToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.IMPORT:
addImportedClassPath(token);
break;
case TokenTypes.CLASS_DEF:
hasServiceClientAnnotation = hasServiceClientAnnotation(token);
if (!hasServiceClientAnnotation) {
return;
}
checkServiceClientNaming(token);
break;
case TokenTypes... | if (!hasServiceClientAnnotation) { | public void visitToken(DetailAST token) {
if (isImplPackage) {
return;
}
switch (token.getType()) {
case TokenTypes.PACKAGE_DEF:
String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText();
isImplPackage = packageName.contains(".implementation");
break;
case TokenTypes.CLASS_DEF:
hasS... | class if it returns a ''sync'' single value.";
private static final Set<String> COMMON_NAMING_PREFIX_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"upsert", "set", "create", "update", "replace", "delete", "add", "get", "list"
)));
private static boolean isAsync;
private static boolean hasServiceClientA... | class ServiceClientInstantiationCheck extends AbstractCheck {
private static final String SERVICE_CLIENT = "ServiceClient";
private static final String BUILDER = "builder";
private static final String ASYNC_CLIENT = "AsyncClient";
private static final String CLIENT = "Client";
private static final String IS_ASYNC = "is... |
I found no way to do an earlier termination of tree traversal, | public void visitToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.IMPORT:
addImportedClassPath(token);
break;
case TokenTypes.CLASS_DEF:
hasServiceClientAnnotation = hasServiceClientAnnotation(token);
if (!hasServiceClientAnnotation) {
return;
}
checkServiceClientNaming(token);
break;
case TokenTypes... | if (!hasServiceClientAnnotation) { | public void visitToken(DetailAST token) {
if (isImplPackage) {
return;
}
switch (token.getType()) {
case TokenTypes.PACKAGE_DEF:
String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText();
isImplPackage = packageName.contains(".implementation");
break;
case TokenTypes.CLASS_DEF:
hasS... | class if it returns a ''sync'' single value.";
private static final Set<String> COMMON_NAMING_PREFIX_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"upsert", "set", "create", "update", "replace", "delete", "add", "get", "list"
)));
private static boolean isAsync;
private static boolean hasServiceClientA... | class ServiceClientInstantiationCheck extends AbstractCheck {
private static final String SERVICE_CLIENT = "ServiceClient";
private static final String BUILDER = "builder";
private static final String ASYNC_CLIENT = "AsyncClient";
private static final String CLIENT = "Client";
private static final String IS_ASYNC = "is... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 6