From 9a9d2851821316f63beed64e79b838d7d79c602c Mon Sep 17 00:00:00 2001 From: lucica28 <57060141+lucica28@users.noreply.github.com> Date: Mon, 29 May 2023 12:06:46 +0300 Subject: [PATCH] delete float operator check (#71) --- src/dscanner/analysis/fish.d | 67 ------------------------------------ src/dscanner/analysis/run.d | 5 --- 2 files changed, 72 deletions(-) delete mode 100644 src/dscanner/analysis/fish.d diff --git a/src/dscanner/analysis/fish.d b/src/dscanner/analysis/fish.d deleted file mode 100644 index 0417e486..00000000 --- a/src/dscanner/analysis/fish.d +++ /dev/null @@ -1,67 +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(string fileName, const(Scope)* sc, bool skipTests = false) - { - super(fileName, sc, skipTests); - } - - 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.line, r.column, 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."); -} diff --git a/src/dscanner/analysis/run.d b/src/dscanner/analysis/run.d index 89a7a175..61b02008 100644 --- a/src/dscanner/analysis/run.d +++ b/src/dscanner/analysis/run.d @@ -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; @@ -481,10 +480,6 @@ MessageSet analyze(string fileName, const Module m, const StaticAnalysisConfig a checks ~= new DuplicateAttributeCheck(fileName, moduleScope, analysisConfig.duplicate_attribute == Check.skipTests && !ut); - if (moduleName.shouldRun!FloatOperatorCheck(analysisConfig)) - checks ~= new FloatOperatorCheck(fileName, moduleScope, - analysisConfig.float_operator_check == Check.skipTests && !ut); - if (moduleName.shouldRun!FunctionAttributeCheck(analysisConfig)) checks ~= new FunctionAttributeCheck(fileName, moduleScope, analysisConfig.function_attribute_check == Check.skipTests && !ut);