virtual-labs-archive / physical-chemistry-iiith

Other
1 stars 64 forks source link

Expected a conditional expression and instead saw an assignment. (no-cond-assign) #47

Open BSravanthi opened 5 years ago

BSravanthi commented 5 years ago

In conditional statements, it is very easy to mistype a comparison operator (such as ==) as an assignment operator (such as =). For example: There are valid reasons to use assignment operators in conditional statements. However, it can be difficult to tell whether a specific assignment was intentional. This rule is aimed at eliminating ambiguous assignments in for, if, while, and do...while conditional statements. The rule takes one option, a string, which must contain one of the following values: except-parens (default): Disallow assignments unless they are enclosed in parentheses. always: Disallow all assignments.

//Bad:
var x;
if (x = 0) {
    var b = 1;
}

//Good:
var x;
if (x == 0) {
    var b = 1;
}

Please refer to the following link to fix similar issues. https://app.codacy.com/app/BSravanthi/physical-chemistry-iiith/issues?&filters=W3siaWQiOiJMYW5ndWFnZSIsInZhbHVlcyI6W251bGxdfSx7ImlkIjoiQ2F0ZWdvcnkiLCJ2YWx1ZXMiOlsiQ29kZSBTdHlsZSJdfSx7ImlkIjoiTGV2ZWwiLCJ2YWx1ZXMiOltudWxsXX0seyJpZCI6IlBhdHRlcm4iLCJ2YWx1ZXMiOlsxNjU1XX0seyJpZCI6IkF1dGhvciIsInZhbHVlcyI6W251bGxdfSx7InZhbHVlcyI6W119XQ==

somashekhar31 commented 5 years ago

commit id:https://github.com/virtual-labs/physical-chemistry-iiith/pull/59/commits/95f22b2278518712f9f0ccb489defe69e5f9dcf4 (all experiments)

snehitharangu commented 5 years ago

Valid fix @somashekhar31

samhithavootkoor commented 5 years ago

validated-2 @somashekhar31