Code Quality detectors
Swallowing exceptions, without re-throwing or logging them, is a bad practice.
In the case of a security-critical event, the product fails to either log the event or misses crucial details in the logged information.
The product unintentionally grants unauthorized actors access to a resource by placing it in the wrong control sphere.
The Process.terminate
API might cause data corruption of shared resources.
APIs with nondeterministic algorithm are used
To always return the subscription ARN, set the ReturnSubscriptionArn
argument to True
.
Non-deterministic ops might return different outputs when run with the same inputs.
Using outdated multiprocessing API calls and parameters is not recommended.
When you process and remove an item from the JoinableQueue
without calling JoinableQueue.task_done()
, a semaphore overflow exception might be thrown.
Recreating AWS clients in each Lambda function invocation is expensive.
Detects if a torch variable is modified in place inside an assignment.
Failure to end a child process that doesn't terminate before its timeout expires can result in leaked resources.
Checks if gradient calculation is disabled during evaluation.
Using the get
method from the dict
class without default values can cause runtime exceptions.
list
replication using replication operator creates references to the existing objects, not copies, which could introduce bugs.
Checks if eval() is called before validating or testing a model.
Always check for new version before fetching the latest version directly.
Best practices to improve the maintainability of notebooks.
This code uses deprecated methods, which suggests that it has not been recently reviewed or maintained.
Synchronous publication of AWS Lambda metrics is inefficient.
Detects if Softmax is used with CrossEntropyLoss.
Catching and re-throwing an exception without further actions is redundant and wasteful.
Response metadata was not checked to verify that it is not None
.
Directly modifying the __dict__
object might cause undesirable behavior due to symbol table modification.
Inefficient regular expression patterns can lead to catastrophic backtracking.
Detects if Softmax is explicitly computed.
Improper error handling can enable attacks and lead to unwanted behavior.
Using naive datetime objects might cause time zone related issues.
Not setting seeds for the random number generators in Pytorch can lead to reproducibility issues.
Improper multiprocessing API usage with wrong parameters might lead to deadlocks.
Classes with low class cohesion contain unrelated operations which make them difficult to understand and less likely to be used.
Notebook has uninitialized variable usage given the execution order
Confusion between equality ==
, !=
and identity is
in conditional expressions can lead to unintended behavior.
The computation of the bceloss using sigmoid values as inputs can be replaced by a single BCEWithLogitsLoss which is numerically more stable.
Using DataLoader with num_workers
greater than 0
can cause increased memory consumption over time when iterating over native Python objects such as list
or dict
.
Checks if Softmax
is used with NLLLoss
function.
Zero out the gradients before doing a backward pass
Sequence modification while iterating over it might cause unexpected bugs.
Throwing a base or generic exception might cause important error information to be lost. This can make your code difficult to maintain.
The product relies on default credentials(including passwords and cryptographic keys) for potentially vital functions.
A variable is re-defined in multiple cells with different types.
Do not pass generic exception.
Default values in Python are created exactly once, when the function is defined. If that object is changed, subsequent calls to the function will refer to the changed object, leading to confusion.
The software does not restrict or incorrectly restrict access to a resource from an unauthorized actor.
Violating PEP8 programming recommendations might make code difficult to read and can introduce ambiguity.
Complex code can be difficult to read and hard to maintain.
The Debug feature should not be enabled or overridden.
Incorrect use of API leads to ambiguity and inconsistency
Detects if nondeterministic tensorflow APIs are used.
Inefficient string concatenation inside loops results in new object creation which adds quadratic runtime cost.
The os.close()
does not work on some platforms.
Not checking which items have failed can lead to loss of data.
Custom polling can be inefficient and prone to error. Consider using AWS waiters instead.
Iteration when only one item is needed from a list is inefficient.
Detects if a random seed is set before random number generation.
Missing authentication checks can lead to unauthorized access to a resource or performance of an action.
Incorrect binding of SNS publish operations with the subscribe
or create_topic
operations might lead to latency issues.
Creating PyTorch tensors on the CPU and then moving them to the device is inefficient.
The constructors for the hashlib
module are faster than new()
Global variables can be dangerous and cause bugs because they can be simultaneously accessed from multiple sections of a program.
Methods that return multiple values can be difficult to read and prone to error.