Skip to content

chore: Add CI check for formatting #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ batch:
env:
env:
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- identifier: static_analysis
buildspec: codebuild/static-analysis.yml
env:
env:
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
1 change: 1 addition & 0 deletions codebuild/corretto11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ phases:
java: corretto11
build:
commands:
- mvn com.coveo:fmt-maven-plugin:check
- mvn install -Dgpg.skip=true "-DtestVectorZip=file://$CODEBUILD_SRC_DIR/src/test/resources/aws-encryption-sdk-test-vectors/vectors/awses-decrypt/python-2.3.0-mrks.zip"
1 change: 1 addition & 0 deletions codebuild/openjdk11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ phases:
java: openjdk11
build:
commands:
- mvn com.coveo:fmt-maven-plugin:check
- mvn install -Dgpg.skip=true "-DtestVectorZip=file://$CODEBUILD_SRC_DIR/src/test/resources/aws-encryption-sdk-test-vectors/vectors/awses-decrypt/python-2.3.0-mrks.zip"
2 changes: 2 additions & 0 deletions codebuild/compliance.yml → codebuild/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ phases:
install:
runtime-versions:
nodejs: 12
java: corretto11
build:
commands:
- mvn com.coveo:fmt-maven-plugin:check
- ./util/test-conditions.sh
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.10</version>
<!-- Configure no goals. -->
<!--Until our CI builds no longer depend on Java 8, skip this during build.-->
<!--We instead manually check this in Java 11 environments to block builds, -->
<!--And additionally check this explicitly through Github Actions.-->
</plugin>
</plugins>
</build>

Expand Down
1,692 changes: 849 additions & 843 deletions src/main/java/com/amazonaws/encryptionsdk/AwsCrypto.java

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions src/main/java/com/amazonaws/encryptionsdk/CommitmentPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@

package com.amazonaws.encryptionsdk;

import com.amazonaws.encryptionsdk.CryptoAlgorithm;

public enum CommitmentPolicy {
ForbidEncryptAllowDecrypt,
RequireEncryptAllowDecrypt,
RequireEncryptRequireDecrypt;
ForbidEncryptAllowDecrypt,
RequireEncryptAllowDecrypt,
RequireEncryptRequireDecrypt;

public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
return !algorithm.isCommitting();
case RequireEncryptAllowDecrypt:
case RequireEncryptRequireDecrypt:
return algorithm.isCommitting();
default:
throw new UnsupportedOperationException("Support for commitment policy " + this + " not yet built.");
}
public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
return !algorithm.isCommitting();
case RequireEncryptAllowDecrypt:
case RequireEncryptRequireDecrypt:
return algorithm.isCommitting();
default:
throw new UnsupportedOperationException(
"Support for commitment policy " + this + " not yet built.");
}
}

public boolean algorithmAllowedForDecrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
case RequireEncryptAllowDecrypt:
return true;
case RequireEncryptRequireDecrypt:
return algorithm.isCommitting();
default:
throw new UnsupportedOperationException("Support for commitment policy " + this + " not yet built.");
}
public boolean algorithmAllowedForDecrypt(CryptoAlgorithm algorithm) {
switch (this) {
case ForbidEncryptAllowDecrypt:
case RequireEncryptAllowDecrypt:
return true;
case RequireEncryptRequireDecrypt:
return algorithm.isCommitting();
default:
throw new UnsupportedOperationException(
"Support for commitment policy " + this + " not yet built.");
}
}
}
Loading