[][src]Struct rslint_core::groups::errors::NoConstantCondition

pub struct NoConstantCondition {}

Disallow constant conditions which always yield one result.

Constant conditions such as if (true) {} are almost always a mistake. Constant conditions always yield a single result which almost always ends up in unwanted behavior. This rule is aimed at catching those conditions in if, do while, while, and for statements, as well as conditional expressions.

Incorrect Code Examples

if (true) {
    //    ^ this block is always used
} else {
//^^^^ this else block is unreachable
}
// This loop endlessly runs
for(foo = 5; 5; foo++) {

}

Correct Code Examples

if (foo) {
    /* */
}

Implementations

impl NoConstantCondition[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for NoConstantCondition[src]

impl CstRule for NoConstantCondition[src]

impl Debug for NoConstantCondition[src]

impl Default for NoConstantCondition[src]

impl<'de> Deserialize<'de> for NoConstantCondition[src]

impl Rule for NoConstantCondition[src]

impl Serialize for NoConstantCondition[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.