Archive
Product
-
Force casts should not be used
Because force casting (as!) does not perform any type safety validations, it is capable of performing dangerous conversions between unrelated types. When the types…
-
Prefer to use an expression body for functions whose body consists of a single expression
Prefer using an expression body for functions with the body consisting of a single expression.
-
Avoid abstract classes without abstract or concrete methods
Abstract classes can have public constructors, and this is required in some particular cases. But a public constructor means that the class can be…
-
Use short variable declarations (:=) for variables with default values
Short variable declarations (:=) should be used if a variable is being set to some value explicitly.
-
Avoid naming unused receivers
If the receiver of a method is unused, do not give it a name. Itβs more readable because itβs clear that the receiver is…
-
Avoid instantiation with new
Use &T{} instead of new(T) when initializing struct references so that it is consistent with the struct initialization.
-
Avoid ‘switch’ with too many ‘case’ statements
When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A real map structure…
-
Variables should not be shadowed
Overriding a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of code. Further, it…
-
Variables should be declared with ‘let’ or ‘const’
The distinction between the variable types created by var and by let is significant, and a switch to let will help alleviate many of…
-
Multiline string literals should not be used
Continuing a string across a linebreak is supported in most script engines, but it is not a part of ECMAScript. Additionally, the whitespace at…