Code Quality detectors

Improper service shutdown

Sudden service shutdown might prevent a graceful termination of threads.

Mandatory method not called after object creation

Mandatory methods must be called after object creation.

Process empty record list in Amazon KCL

Setting withCallProcessRecordsEvenForEmptyRecordList to TRUE during Kinesis Client Library (KCL) initialization will treat empty records differently.

AWS object presence check

Manually performing an object existence check is inefficient when a built-in operation is available.

Missing timeout check on CountDownLatch.await

Missing timeout check on CountDownLatch.await can cause synchronization errors.

Preserve thread interruption status rule

Preserve Thread Interruption Status Rule.

Missing timeout check on ExecutorService.awaitTermination

Missing timeout checks on awaitTermination might make the code harder to debug.

Region specification missing from AWS client initialization

Set an explicit AWS Region to avoid cold start delays in AWS client initialization.

Custom manual retries of AWS SDK calls

Custom manual retries of calls to AWS SDK APIs are inefficient.

Missing null check for cache response metadata

Accessing the cache response metadata without performing a null check might cause a null dereference error.

Inefficient usage of Transaction library from AWS Labs

The AWS Labs Transactions Library is a client-side solution and less efficient compared to DynamoDB native transactions.

Use of a deprecated method

This code uses deprecated methods, which suggests that it has not been recently reviewed or maintained.

Inefficient Amazon S3 manual pagination

Use S3Objects.withPrefix() instead of manually paginating results.

Use of inefficient APIs

Performance of this code can be enhanced by using alternative APIs.

Low maintainability with old Android features

Code uses older Android features.

Missing statement to record cause of InvocationTargetException

Missing statements to record the underlying cause of InvocationTargetException.

Misconfigured Concurrency

Misconfigured CompletableFuture.get or Future.get.

Inefficient polling of AWS resource

Custom polling can be inefficient and prone to error. Consider using AWS waiters instead.

Syntax error in file

Some files contain syntax errors.

Client constructor deprecation

Client constructors are now deprecated in favor of using builders to create the client.

Inefficient use of stream sorting

Using Stream::min or Stream::max is more efficient than sorting and getting the first element in a stream.

Simplifiable code

Simplifiable code might be harder to read or maintain.

Long polling is not enabled in Amazon SQS

Enable long polling for efficiency.

Manual pagination

Suggest using auto-pagination instead of manual pagination.

Incorrect string equality operator

Use equals(), not ==, when checking if two strings are equal.

Inefficient chain of AWS API calls

The chain of API calls can be replaced with a single, more efficient API call.

Do not catch and throw exception

Do not catch and throw the same exception.

Code clone

Similar code fragments were detected in the same file.

Not recommended aws credentials classes

Find usages of not recommended classes for AWS Credentials and suggest replacing them with something else.

Missing check on method output

Missing checks might cause silent failures that are harder to debug.

Missing byte array length of JSON parser

Specify the length of the input byte array when creating a JSON parser to avoid a deserialization problem.

Missing position check before getting substring

Getting a substring outside the range of a string can cause an index-out-of-bounds exception.

Low maintainability with low class cohesion

Classes with low class cohesion contain unrelated operations which make them difficult to understand and less likely to be used.

Oversynchronization

Oversynchronization with ConcurrentHashMap or ConcurrentLinkedQueue can reduce program performance.

Backward compatibility breaks with error message parsing

Maintain your code's backward compatibility by checking the status code instead of parsing the error message.

Inefficient map entry iteration

Iterating on Map entries is more efficient than iterating on the keys and asking for their respective values.

AWS DynamoDB getItem output is not null checked

Outputs of AWS DynamoDB's GetItem method are not null checked.

Infinite loop

Use loop control flow to ensure that loops are exited, even if exceptional behaviors are encountered.

Batch operations preferred over looping

Batch operations are more efficient than looping to process several items at the same time.

Synchronous publication of AWS Lambda metrics

Synchronous publication of AWS Lambda metrics is inefficient.

Improper use of classes that aren't thread-safe

Improper use of thread-unsafe classes in multi-threaded programs can cause the programs to be unstable.

Incorrect null check before setting a value

When a variable is assigned a value after checking if it's not null (for example, x != null insead of x == null), it might be inadvertently overwritten.

Insufficient use of name in Amazon SQS queue

Provide the full URL for the Amazon SQS queue.

Amazon SQS message visibility changed without a status check

When you change Amazon SQS message visibility, check for MessageNotInFlight exceptions.

State machine execution ARN is not logged

Log the ARN identifying the state machine execution for better debuggability.

Use Stream::anyMatch instead of Stream::findFirst or Stream::findAny

Using Stream::anyMatch is more readable and convenient than using a chain of Stream::filter, Stream::findFirst or Stream::findAny and Optional::isPresent.

Use an enum to specify an AWS Region

To minimize the risk of error, use an enum instead of a string to specify an AWS Region.

Batch request with unchecked failures

Not checking which items have failed can lead to loss of data.

Improperly formatted string arguments

Format strings appropriately for their argument types. For example, use %d, not %s, for integers.