mirror of
https://github.com/dlang-community/D-Scanner.git
synced 2025-04-28 22:30:04 +03:00
Delete CommaExpressionCheck (#104)
This commit is contained in:
parent
ffce05181e
commit
030481b757
3 changed files with 3 additions and 68 deletions
3
changelog/dscanner.comma-expression.dd
Normal file
3
changelog/dscanner.comma-expression.dd
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Remove the check for comma expression check
|
||||||
|
e.g. (int a = 3, a + 7)
|
||||||
|
This check is no longer necessary since comma expression have been removed from the D language.
|
|
@ -1,63 +0,0 @@
|
||||||
// Copyright Brian Schott (Hackerpilot) 2014.
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
module dscanner.analysis.comma_expression;
|
|
||||||
|
|
||||||
import dparse.ast;
|
|
||||||
import dparse.lexer;
|
|
||||||
import dscanner.analysis.base;
|
|
||||||
import dsymbol.scope_;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for uses of the comma expression.
|
|
||||||
*/
|
|
||||||
final class CommaExpressionCheck : BaseAnalyzer
|
|
||||||
{
|
|
||||||
alias visit = BaseAnalyzer.visit;
|
|
||||||
|
|
||||||
mixin AnalyzerInfo!"comma_expression_check";
|
|
||||||
|
|
||||||
this(BaseAnalyzerArguments args)
|
|
||||||
{
|
|
||||||
super(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
override void visit(const Expression ex)
|
|
||||||
{
|
|
||||||
if (ex.items.length > 1 && interest > 0)
|
|
||||||
{
|
|
||||||
addErrorMessage(ex, KEY, "Avoid using the comma expression.");
|
|
||||||
}
|
|
||||||
ex.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override void visit(const AssignExpression ex)
|
|
||||||
{
|
|
||||||
++interest;
|
|
||||||
ex.accept(this);
|
|
||||||
--interest;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dconf 2016
|
|
||||||
override void visit(const SynchronizedStatement ss)
|
|
||||||
{
|
|
||||||
if (ss.expression !is null)
|
|
||||||
{
|
|
||||||
++interest;
|
|
||||||
visit(ss.expression);
|
|
||||||
--interest;
|
|
||||||
}
|
|
||||||
visit(ss.statementNoCaseNoDefault);
|
|
||||||
}
|
|
||||||
|
|
||||||
invariant
|
|
||||||
{
|
|
||||||
assert(interest >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int interest;
|
|
||||||
|
|
||||||
private enum string KEY = "dscanner.suspicious.comma_expression";
|
|
||||||
}
|
|
|
@ -47,7 +47,6 @@ import dscanner.analysis.asm_style;
|
||||||
import dscanner.analysis.logic_precedence;
|
import dscanner.analysis.logic_precedence;
|
||||||
import dscanner.analysis.stats_collector;
|
import dscanner.analysis.stats_collector;
|
||||||
import dscanner.analysis.undocumented;
|
import dscanner.analysis.undocumented;
|
||||||
import dscanner.analysis.comma_expression;
|
|
||||||
import dscanner.analysis.function_attributes;
|
import dscanner.analysis.function_attributes;
|
||||||
import dscanner.analysis.local_imports;
|
import dscanner.analysis.local_imports;
|
||||||
import dscanner.analysis.unmodified;
|
import dscanner.analysis.unmodified;
|
||||||
|
@ -830,10 +829,6 @@ private BaseAnalyzer[] getAnalyzersForModuleAndConfig(string fileName,
|
||||||
moduleScope
|
moduleScope
|
||||||
);
|
);
|
||||||
|
|
||||||
if (moduleName.shouldRun!CommaExpressionCheck(analysisConfig))
|
|
||||||
checks ~= new CommaExpressionCheck(args.setSkipTests(
|
|
||||||
analysisConfig.comma_expression_check == Check.skipTests && !ut));
|
|
||||||
|
|
||||||
if (moduleName.shouldRun!UnmodifiedFinder(analysisConfig))
|
if (moduleName.shouldRun!UnmodifiedFinder(analysisConfig))
|
||||||
checks ~= new UnmodifiedFinder(args.setSkipTests(
|
checks ~= new UnmodifiedFinder(args.setSkipTests(
|
||||||
analysisConfig.could_be_immutable_check == Check.skipTests && !ut));
|
analysisConfig.could_be_immutable_check == Check.skipTests && !ut));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue