Skip to content

Commit

Permalink
Change import checkstyle configuration and fix all import violations (#…
Browse files Browse the repository at this point in the history
…136)

* change import checkstyle

* update import order rules and fix all ImportOrder checkstyle violations

* add a comment about checkstyle to CONTRIBUTING.md

* Change hyperlink to checkstyle.xml for clarity

* reduce allowed checkstyle violations to the current violations

Co-authored-by: Thomas Poepping <[email protected]>
  • Loading branch information
PoeppingT and Thomas Poepping authored Oct 29, 2021
1 parent 0380a12 commit 4f2be07
Show file tree
Hide file tree
Showing 39 changed files with 95 additions and 123 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To send us a pull request, please:

1. Fork the repository.
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3. Ensure local tests pass.
3. Ensure local checks pass, including test, checkstyle, and spotbugs. Our checkstyle rules are closely patterned after the IntelliJ IDE's defaults and can be found in [resources/checkstyle/checkstyle.xml](resources/checkstyle/checkstyle.xml).
4. Commit to your fork using clear commit messages.
5. Send us a pull request, answering any default questions in the pull request interface.
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
Expand Down
2 changes: 1 addition & 1 deletion functions/alb-update/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>30</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>25</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/ecs-deploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>24</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>17</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/ecs-service-update/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>8</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>5</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/ecs-shutdown-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>11</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>8</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/ecs-startup-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>15</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>12</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/onboarding-notification/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>23</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>16</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion functions/system-rest-api-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>16</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>9</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion installer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>138</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>104</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion layers/apigw-helper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>24</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>9</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion layers/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>342</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>334</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion metering-billing/lambdas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ limitations under the License.
</licenses>

<properties>
<checkstyle.maxAllowedViolations>208</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>136</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@
*/
package com.amazon.aws.partners.saasfactory.metering.aggregation;

import java.io.InputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;

import com.amazon.aws.partners.saasfactory.metering.common.BillingEvent;
import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import com.amazon.aws.partners.saasfactory.saasboost.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.ConditionalCheckFailedException;
Expand All @@ -44,17 +31,21 @@
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;
import software.amazon.awssdk.services.dynamodb.model.TransactionCanceledException;
import software.amazon.awssdk.services.dynamodb.model.TransactWriteItem;
import software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest;
import software.amazon.awssdk.services.dynamodb.model.TransactionCanceledException;
import software.amazon.awssdk.services.dynamodb.model.Update;

import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import com.amazon.aws.partners.saasfactory.metering.common.BillingEvent;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.stream.Collectors;

import static com.amazon.aws.partners.saasfactory.metering.common.Constants.*;


public class BillingEventAggregation implements RequestStreamHandler {

private final DynamoDbClient ddb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,33 @@
*/
package com.amazon.aws.partners.saasfactory.metering.aggregation;

import java.io.InputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.amazon.aws.partners.saasfactory.metering.common.AggregationEntry;
import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import com.amazon.aws.partners.saasfactory.saasboost.ApiGatewayHelper;
import com.amazon.aws.partners.saasfactory.saasboost.ApiRequest;
import com.amazon.aws.partners.saasfactory.saasboost.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;

import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.InternalServerErrorException;
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;
import software.amazon.awssdk.services.dynamodb.model.TransactionCanceledException;
import software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest;

import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.UsageRecord;
import com.stripe.net.RequestOptions;
import com.stripe.param.UsageRecordCreateOnSubscriptionItemParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.*;

import com.amazon.aws.partners.saasfactory.metering.common.AggregationEntry;
import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.amazon.aws.partners.saasfactory.metering.common.Constants.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@
*/
package com.amazon.aws.partners.saasfactory.metering.billing;

import java.time.Instant;
import java.util.HashMap;
import java.util.Map;

import com.amazon.aws.partners.saasfactory.metering.common.BillingEvent;
import com.amazon.aws.partners.saasfactory.metering.common.ProcessBillingEventException;
import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import com.amazon.aws.partners.saasfactory.metering.onboarding.OnboardTenantProduct;
import com.amazon.aws.partners.saasfactory.saasboost.Utils;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.amazonaws.services.lambda.runtime.Context;

import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.InternalServerErrorException;
import software.amazon.awssdk.services.dynamodb.model.PutItemRequest;
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;

import com.amazon.aws.partners.saasfactory.metering.common.BillingEvent;
import com.amazon.aws.partners.saasfactory.metering.common.TenantConfiguration;
import com.amazon.aws.partners.saasfactory.metering.common.ProcessBillingEventException;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;

import static com.amazon.aws.partners.saasfactory.metering.common.Constants.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@
package com.amazon.aws.partners.saasfactory.metering.common;

import org.slf4j.Logger;

import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
import software.amazon.awssdk.core.SdkSystemSetting;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;

import java.net.URI;
import java.net.URISyntaxException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.UUID;
import java.time.Instant;

public final class Constants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
*/
package com.amazon.aws.partners.saasfactory.metering.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;

import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest;
Expand All @@ -30,15 +24,20 @@
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.amazon.aws.partners.saasfactory.metering.common.Constants.CONFIG_EXPRESSION_NAME;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.CONFIG_EXPRESSION_VALUE;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.CONFIG_INDEX_NAME_ENV_VARIABLE;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.CONFIG_SORT_KEY_VALUE;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.PRIMARY_KEY_NAME;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.SORT_KEY_NAME;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.SUBSCRIPTION_MAPPING_ATTRIBUTE_NAME;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.getEnvVariable;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.formatTenantEntry;
import static com.amazon.aws.partners.saasfactory.metering.common.Constants.getEnvVariable;

public class TenantConfiguration {

Expand Down
2 changes: 1 addition & 1 deletion metrics-analytics/metrics-java-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License.

<properties>
<java.version>1.8</java.version>
<checkstyle.maxAllowedViolations>26</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>25</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.Objects;

public class Metric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
package com.amazonaws.saas.metrics;

import com.amazonaws.saas.metrics.MetricEvent.Type;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class MetricEventBuilder {
private static final Logger logger = LoggerFactory.getLogger(MetricEventBuilder.class);
private MetricEvent metricEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import io.netty.util.CharsetUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.core.SdkBytes;
Expand All @@ -28,6 +25,10 @@
import software.amazon.awssdk.services.firehose.model.PutRecordBatchRequest;
import software.amazon.awssdk.services.firehose.model.Record;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MetricEventLogger {
private static final Logger logger = LoggerFactory.getLogger(MetricEventLogger.class);
public static final int DEFAULT_FLUSH_TIME_IN_SECS = 60;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.Objects;

public class Tenant {
Expand Down
2 changes: 1 addition & 1 deletion resources/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
<property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
</module>
<module name="MethodParamPad">
Expand Down
2 changes: 1 addition & 1 deletion resources/custom-resources/cidr-dynamodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ limitations under the License.
</license>
</licenses>
<properties>
<checkstyle.maxAllowedViolations>16</checkstyle.maxAllowedViolations>
<checkstyle.maxAllowedViolations>7</checkstyle.maxAllowedViolations>
</properties>

<build>
Expand Down
Loading

0 comments on commit 4f2be07

Please sign in to comment.