Inspectopedia
 
2024.3

Redundant type conversion

Info
Code Style
Last modified: 03 December 2024

Reports type conversions that may be omitted.

Example:

var s = string("hello")

The "hello" value is the string type already, the additional conversion to string is redundant. To remove the conversion, consider using the Delete conversion quick-fix.

After the quick-fix is applied:

var s = "hello"

Sometimes conversion of a floating expression to a floating type can be intentional (refer to this issue as an example). In such cases, the IDE issues a warning about a possibly redundant conversion.