delete float operator check (#71)
This commit is contained in:
parent
a7545fc9d2
commit
b45b268c0c
|
|
@ -1,75 +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.fish;
|
||||
|
||||
import std.stdio;
|
||||
import dparse.ast;
|
||||
import dparse.lexer;
|
||||
import dscanner.analysis.base;
|
||||
import dscanner.analysis.helpers;
|
||||
import dsymbol.scope_ : Scope;
|
||||
|
||||
/**
|
||||
* Checks for use of the deprecated floating point comparison operators.
|
||||
*/
|
||||
final class FloatOperatorCheck : BaseAnalyzer
|
||||
{
|
||||
alias visit = BaseAnalyzer.visit;
|
||||
|
||||
enum string KEY = "dscanner.deprecated.floating_point_operators";
|
||||
mixin AnalyzerInfo!"float_operator_check";
|
||||
|
||||
this(BaseAnalyzerArguments args)
|
||||
{
|
||||
super(args);
|
||||
}
|
||||
|
||||
override void visit(const RelExpression r)
|
||||
{
|
||||
if (r.operator == tok!"<>" || r.operator == tok!"<>="
|
||||
|| r.operator == tok!"!<>" || r.operator == tok!"!>"
|
||||
|| r.operator == tok!"!<" || r.operator == tok!"!<>="
|
||||
|| r.operator == tok!"!>=" || r.operator == tok!"!<=")
|
||||
{
|
||||
addErrorMessage(r, KEY,
|
||||
"Avoid using the deprecated floating-point operators.");
|
||||
}
|
||||
r.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
import dscanner.analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||
|
||||
StaticAnalysisConfig sac = disabledConfig();
|
||||
sac.float_operator_check = Check.enabled;
|
||||
assertAnalyzerWarnings(q{
|
||||
void testFish()
|
||||
{
|
||||
float z = 1.5f;
|
||||
bool a;
|
||||
a = z !<>= z; /+
|
||||
^^^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z !<> z; /+
|
||||
^^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z <> z; /+
|
||||
^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z <>= z; /+
|
||||
^^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z !> z; /+
|
||||
^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z !>= z; /+
|
||||
^^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z !< z; /+
|
||||
^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
a = z !<= z; /+
|
||||
^^^^^^^ [warn]: Avoid using the deprecated floating-point operators. +/
|
||||
}
|
||||
}c, sac);
|
||||
|
||||
stderr.writeln("Unittest for FloatOperatorCheck passed.");
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@ import dscanner.analysis.style;
|
|||
import dscanner.analysis.enumarrayliteral;
|
||||
import dscanner.analysis.pokemon;
|
||||
import dscanner.analysis.del;
|
||||
import dscanner.analysis.fish;
|
||||
import dscanner.analysis.numbers;
|
||||
import dscanner.analysis.objectconst;
|
||||
import dscanner.analysis.range;
|
||||
|
|
@ -811,14 +810,6 @@ unittest
|
|||
assert(test("std.bar.foo", "-barr,+bar"));
|
||||
}
|
||||
|
||||
private
|
||||
{
|
||||
version (unittest)
|
||||
enum ut = true;
|
||||
else
|
||||
enum ut = false;
|
||||
}
|
||||
|
||||
private BaseAnalyzer[] getAnalyzersForModuleAndConfig(string fileName,
|
||||
const(Token)[] tokens, const Module m,
|
||||
const StaticAnalysisConfig analysisConfig, const Scope* moduleScope)
|
||||
|
|
@ -853,10 +844,6 @@ private BaseAnalyzer[] getAnalyzersForModuleAndConfig(string fileName,
|
|||
checks ~= new DuplicateAttributeCheck(args.setSkipTests(
|
||||
analysisConfig.duplicate_attribute == Check.skipTests && !ut));
|
||||
|
||||
if (moduleName.shouldRun!FloatOperatorCheck(analysisConfig))
|
||||
checks ~= new FloatOperatorCheck(args.setSkipTests(
|
||||
analysisConfig.float_operator_check == Check.skipTests && !ut));
|
||||
|
||||
if (moduleName.shouldRun!FunctionAttributeCheck(analysisConfig))
|
||||
checks ~= new FunctionAttributeCheck(args.setSkipTests(
|
||||
analysisConfig.function_attribute_check == Check.skipTests && !ut));
|
||||
|
|
|
|||
Loading…
Reference in New Issue