From ea25aad84f6b73a96884ff631d0dc5eebec238be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Mon, 16 Aug 2021 00:09:18 +0200 Subject: [PATCH 01/16] Use @safe: at the beginning --- makefile | 7 +- src/dscanner/analysis/allman.d | 1 + src/dscanner/analysis/asm_style.d | 2 + src/dscanner/analysis/assert_without_msg.d | 2 + src/dscanner/analysis/auto_function.d | 2 + src/dscanner/analysis/auto_ref_assignment.d | 2 + src/dscanner/analysis/base.d | 4 +- .../analysis/builtin_property_names.d | 2 + src/dscanner/analysis/comma_expression.d | 2 + src/dscanner/analysis/config.d | 2 + src/dscanner/analysis/constructors.d | 2 + src/dscanner/analysis/del.d | 2 + src/dscanner/analysis/duplicate_attribute.d | 2 + src/dscanner/analysis/enumarrayliteral.d | 4 +- src/dscanner/analysis/final_attribute.d | 2 + src/dscanner/analysis/fish.d | 2 + src/dscanner/analysis/has_public_example.d | 3 +- src/dscanner/analysis/helpers.d | 2 + src/dscanner/analysis/if_constraints_indent.d | 2 + src/dscanner/analysis/if_statements.d | 2 + src/dscanner/analysis/ifelsesame.d | 2 + src/dscanner/analysis/imports_sortedness.d | 2 + .../analysis/incorrect_infinite_range.d | 2 + .../analysis/label_var_same_name_check.d | 2 + src/dscanner/analysis/lambda_return_check.d | 2 + src/dscanner/analysis/length_subtraction.d | 2 + src/dscanner/analysis/line_length.d | 2 + src/dscanner/analysis/local_imports.d | 2 + src/dscanner/analysis/logic_precedence.d | 2 + src/dscanner/analysis/mismatched_args.d | 2 + src/dscanner/analysis/numbers.d | 2 + .../analysis/opequals_without_tohash.d | 2 + src/dscanner/analysis/range.d | 2 + src/dscanner/analysis/redundant_attributes.d | 4 +- src/dscanner/analysis/redundant_parens.d | 2 + src/dscanner/analysis/run.d | 3 +- src/dscanner/analysis/static_if_else.d | 4 +- src/dscanner/analysis/stats_collector.d | 2 + src/dscanner/analysis/style.d | 2 + src/dscanner/analysis/trust_too_much.d | 2 + src/dscanner/analysis/undocumented.d | 7 +- src/dscanner/analysis/unmodified.d | 3 +- src/dscanner/analysis/unused.d | 2 + src/dscanner/analysis/unused_label.d | 2 + src/dscanner/analysis/unused_result.d | 3 +- src/dscanner/analysis/unused_variable.d | 2 + src/dscanner/analysis/useless_assert.d | 2 + src/dscanner/analysis/useless_initializer.d | 3 +- src/dscanner/analysis/vcall_in_ctor.d | 3 +- src/dscanner/etags.d | 2 +- src/dscanner/highlighter.d | 14 +++- src/dscanner/main.d | 82 +++++++++++-------- src/dscanner/reports.d | 8 +- src/dscanner/stats.d | 2 + src/dscanner/symbol_finder.d | 6 +- src/dscanner/utils.d | 18 ++-- 56 files changed, 187 insertions(+), 66 deletions(-) diff --git a/makefile b/makefile index 20b9801d..b4d5a3b1 100644 --- a/makefile +++ b/makefile @@ -27,13 +27,14 @@ INCLUDE_PATHS = \ -Ilibddoc/common/source \ -Istdx-allocator/source VERSIONS = -DEBUG_VERSIONS = -version=dparse_verbose -DMD_FLAGS = -w -release -O -Jbin -od${OBJ_DIR} -version=StdLoggerDisableWarning +DEBUG_VERSIONS = -version=StdLoggerDisableWarning +# DEBUG_VERSIONS = -version=StdLoggerDisableWarning +DMD_FLAGS = -w -g -Jbin -od${OBJ_DIR} -version=StdLoggerDisableWarning override DMD_FLAGS += $(DFLAGS) override LDC_FLAGS += $(DFLAGS) override GDC_FLAGS += $(DFLAGS) DMD_TEST_FLAGS = -w -g -Jbin -version=StdLoggerDisableWarning -override LDC_FLAGS += -O5 -release -oq -d-version=StdLoggerDisableWarning +override LDC_FLAGS += --d-debug -g -oq -d-version=StdLoggerDisableWarning -fsanitize=address -link-defaultlib-debug override GDC_FLAGS += -O3 -frelease -d-version=StdLoggerDisableWarning SHELL:=/usr/bin/env bash diff --git a/src/dscanner/analysis/allman.d b/src/dscanner/analysis/allman.d index 2cbd9ccc..dea1473c 100644 --- a/src/dscanner/analysis/allman.d +++ b/src/dscanner/analysis/allman.d @@ -12,6 +12,7 @@ import dsymbol.scope_ : Scope; import std.algorithm; import std.range; + /** Checks for the allman style (braces should be on their own line) ------------ diff --git a/src/dscanner/analysis/asm_style.d b/src/dscanner/analysis/asm_style.d index de54c773..68dc1f57 100644 --- a/src/dscanner/analysis/asm_style.d +++ b/src/dscanner/analysis/asm_style.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for confusing asm expressions. * See_also: $(LINK https://issues.dlang.org/show_bug.cgi?id=9738) diff --git a/src/dscanner/analysis/assert_without_msg.d b/src/dscanner/analysis/assert_without_msg.d index e24c9891..2447ede7 100644 --- a/src/dscanner/analysis/assert_without_msg.d +++ b/src/dscanner/analysis/assert_without_msg.d @@ -13,6 +13,8 @@ import dparse.ast; import std.stdio; import std.algorithm; + + /** * Check that all asserts have an explanatory message. */ diff --git a/src/dscanner/analysis/auto_function.d b/src/dscanner/analysis/auto_function.d index 659dbff5..f8853a01 100644 --- a/src/dscanner/analysis/auto_function.d +++ b/src/dscanner/analysis/auto_function.d @@ -13,6 +13,8 @@ import dparse.lexer; import std.stdio; import std.algorithm.searching : any; + + /** * Checks for auto functions without return statement. * diff --git a/src/dscanner/analysis/auto_ref_assignment.d b/src/dscanner/analysis/auto_ref_assignment.d index dbd57609..7c1b9dc6 100644 --- a/src/dscanner/analysis/auto_ref_assignment.d +++ b/src/dscanner/analysis/auto_ref_assignment.d @@ -9,6 +9,8 @@ import dparse.lexer; import dparse.ast; import dscanner.analysis.base; + + /** * Checks for assignment to auto-ref function parameters. */ diff --git a/src/dscanner/analysis/base.d b/src/dscanner/analysis/base.d index 0b92a5c2..fbd15f04 100644 --- a/src/dscanner/analysis/base.d +++ b/src/dscanner/analysis/base.d @@ -6,6 +6,8 @@ import dparse.ast; import std.array; import dsymbol.scope_ : Scope; + + struct Message { /// Name of the file where the warning was triggered @@ -81,7 +83,7 @@ protected: override void visit(const T structDec) { inAggregate = true; - structDec.accept(this); + () @trusted { structDec.accept(this); } (); inAggregate = false; } } diff --git a/src/dscanner/analysis/builtin_property_names.d b/src/dscanner/analysis/builtin_property_names.d index cadc2209..6f7148a8 100644 --- a/src/dscanner/analysis/builtin_property_names.d +++ b/src/dscanner/analysis/builtin_property_names.d @@ -14,6 +14,8 @@ import dscanner.analysis.helpers; import dsymbol.scope_; import std.algorithm : map; + + /** * The following code should be killed with fire: * --- diff --git a/src/dscanner/analysis/comma_expression.d b/src/dscanner/analysis/comma_expression.d index 45c7d683..eed64939 100644 --- a/src/dscanner/analysis/comma_expression.d +++ b/src/dscanner/analysis/comma_expression.d @@ -10,6 +10,8 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; + + /** * Check for uses of the comma expression. */ diff --git a/src/dscanner/analysis/config.d b/src/dscanner/analysis/config.d index c917e66e..29337f40 100644 --- a/src/dscanner/analysis/config.d +++ b/src/dscanner/analysis/config.d @@ -7,6 +7,8 @@ module dscanner.analysis.config; import inifiled; + + /// Returns: A default configuration. StaticAnalysisConfig defaultStaticAnalysisConfig() { diff --git a/src/dscanner/analysis/constructors.d b/src/dscanner/analysis/constructors.d index 2a65e069..dedbd0b2 100644 --- a/src/dscanner/analysis/constructors.d +++ b/src/dscanner/analysis/constructors.d @@ -7,6 +7,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + final class ConstructorCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/del.d b/src/dscanner/analysis/del.d index 99ca6408..81b4d60c 100644 --- a/src/dscanner/analysis/del.d +++ b/src/dscanner/analysis/del.d @@ -11,6 +11,8 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; + + /** * Checks for use of the deprecated 'delete' keyword */ diff --git a/src/dscanner/analysis/duplicate_attribute.d b/src/dscanner/analysis/duplicate_attribute.d index 539da980..7585c02a 100644 --- a/src/dscanner/analysis/duplicate_attribute.d +++ b/src/dscanner/analysis/duplicate_attribute.d @@ -13,6 +13,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for duplicate attributes such as @property, @safe, * @trusted, @system, pure, and nothrow diff --git a/src/dscanner/analysis/enumarrayliteral.d b/src/dscanner/analysis/enumarrayliteral.d index c52c7261..3b88b86b 100644 --- a/src/dscanner/analysis/enumarrayliteral.d +++ b/src/dscanner/analysis/enumarrayliteral.d @@ -11,6 +11,8 @@ import dscanner.analysis.base; import std.algorithm : canFind, map; import dsymbol.scope_ : Scope; + + void doNothing(string, size_t, size_t, string, bool) { } @@ -52,6 +54,6 @@ final class EnumArrayLiteralCheck : BaseAnalyzer ~ part.identifier.text ~ " = [ ...' instead."); } } - autoDec.accept(this); + () @trusted { autoDec.accept(this); } (); } } diff --git a/src/dscanner/analysis/final_attribute.d b/src/dscanner/analysis/final_attribute.d index 8df2adbf..57549a15 100644 --- a/src/dscanner/analysis/final_attribute.d +++ b/src/dscanner/analysis/final_attribute.d @@ -10,6 +10,8 @@ import dscanner.analysis.helpers; import dparse.ast; import dparse.lexer; + + /** * Checks for useless usage of the final attribute. * diff --git a/src/dscanner/analysis/fish.d b/src/dscanner/analysis/fish.d index 0417e486..7cbf987d 100644 --- a/src/dscanner/analysis/fish.d +++ b/src/dscanner/analysis/fish.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for use of the deprecated floating point comparison operators. */ diff --git a/src/dscanner/analysis/has_public_example.d b/src/dscanner/analysis/has_public_example.d index 0d82977e..ffeeb5d1 100644 --- a/src/dscanner/analysis/has_public_example.d +++ b/src/dscanner/analysis/has_public_example.d @@ -12,6 +12,8 @@ import dparse.lexer; import std.algorithm; import std.stdio; + + /** * Checks for public declarations without a documented unittests. * For now, variable and enum declarations aren't checked. @@ -332,4 +334,3 @@ unittest stderr.writeln("Unittest for HasPublicExampleCheck passed."); } - diff --git a/src/dscanner/analysis/helpers.d b/src/dscanner/analysis/helpers.d index 98c817b4..5240946d 100644 --- a/src/dscanner/analysis/helpers.d +++ b/src/dscanner/analysis/helpers.d @@ -19,6 +19,8 @@ import dscanner.analysis.base; import stdx.allocator.mallocator; import stdx.allocator; + + S between(S)(S value, S before, S after) if (isSomeString!S) { return value.after(before).before(after); diff --git a/src/dscanner/analysis/if_constraints_indent.d b/src/dscanner/analysis/if_constraints_indent.d index 9757c07a..e12d1042 100644 --- a/src/dscanner/analysis/if_constraints_indent.d +++ b/src/dscanner/analysis/if_constraints_indent.d @@ -12,6 +12,8 @@ import dsymbol.scope_ : Scope; import std.algorithm.iteration : filter; import std.range; + + /** Checks whether all if constraints have the same indention as their declaration. */ diff --git a/src/dscanner/analysis/if_statements.d b/src/dscanner/analysis/if_statements.d index a70aec5d..86f4feb5 100644 --- a/src/dscanner/analysis/if_statements.d +++ b/src/dscanner/analysis/if_statements.d @@ -10,6 +10,8 @@ import dparse.formatter; import dscanner.analysis.base; import dsymbol.scope_ : Scope; + + final class IfStatementCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/ifelsesame.d b/src/dscanner/analysis/ifelsesame.d index e757b91d..32fc6a41 100644 --- a/src/dscanner/analysis/ifelsesame.d +++ b/src/dscanner/analysis/ifelsesame.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for duplicated code in conditional and logical expressions. * $(UL diff --git a/src/dscanner/analysis/imports_sortedness.d b/src/dscanner/analysis/imports_sortedness.d index 4f33fd4b..b14c1e47 100644 --- a/src/dscanner/analysis/imports_sortedness.d +++ b/src/dscanner/analysis/imports_sortedness.d @@ -10,6 +10,8 @@ import dparse.ast; import std.stdio; + + /** * Checks the sortedness of module imports */ diff --git a/src/dscanner/analysis/incorrect_infinite_range.d b/src/dscanner/analysis/incorrect_infinite_range.d index 1df6b3e0..5990639f 100644 --- a/src/dscanner/analysis/incorrect_infinite_range.d +++ b/src/dscanner/analysis/incorrect_infinite_range.d @@ -10,6 +10,8 @@ import dscanner.analysis.helpers; import dparse.ast; import dparse.lexer; + + /** * Checks for incorrect infinite range definitions */ diff --git a/src/dscanner/analysis/label_var_same_name_check.d b/src/dscanner/analysis/label_var_same_name_check.d index dc85bdb6..b293e024 100644 --- a/src/dscanner/analysis/label_var_same_name_check.d +++ b/src/dscanner/analysis/label_var_same_name_check.d @@ -10,6 +10,8 @@ import dsymbol.scope_ : Scope; import dscanner.analysis.base; import dscanner.analysis.helpers; + + /** * Checks for labels and variables that have the same name. */ diff --git a/src/dscanner/analysis/lambda_return_check.d b/src/dscanner/analysis/lambda_return_check.d index e0b0b473..6cdba625 100644 --- a/src/dscanner/analysis/lambda_return_check.d +++ b/src/dscanner/analysis/lambda_return_check.d @@ -10,6 +10,8 @@ import dparse.lexer; import dscanner.analysis.base; import dscanner.utils : safeAccess; + + final class LambdaReturnCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/length_subtraction.d b/src/dscanner/analysis/length_subtraction.d index a788ec76..a07a13a4 100644 --- a/src/dscanner/analysis/length_subtraction.d +++ b/src/dscanner/analysis/length_subtraction.d @@ -13,6 +13,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; + + /** * Checks for subtraction from a .length property. This is usually a bug. */ diff --git a/src/dscanner/analysis/line_length.d b/src/dscanner/analysis/line_length.d index f10c3d2e..1c3b1113 100644 --- a/src/dscanner/analysis/line_length.d +++ b/src/dscanner/analysis/line_length.d @@ -12,6 +12,8 @@ import dparse.lexer; import std.typecons : tuple, Tuple; + + /** * Checks for lines longer than 120 characters */ diff --git a/src/dscanner/analysis/local_imports.d b/src/dscanner/analysis/local_imports.d index 4489ce7d..6e342e84 100644 --- a/src/dscanner/analysis/local_imports.d +++ b/src/dscanner/analysis/local_imports.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; + + /** * Checks for local imports that import all symbols. * See_also: $(LINK https://issues.dlang.org/show_bug.cgi?id=10378) diff --git a/src/dscanner/analysis/logic_precedence.d b/src/dscanner/analysis/logic_precedence.d index 35d36338..d6bf1194 100644 --- a/src/dscanner/analysis/logic_precedence.d +++ b/src/dscanner/analysis/logic_precedence.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; + + /** * Checks for code with confusing && and || operator precedence * --- diff --git a/src/dscanner/analysis/mismatched_args.d b/src/dscanner/analysis/mismatched_args.d index a25ce0e5..2a5e2b16 100644 --- a/src/dscanner/analysis/mismatched_args.d +++ b/src/dscanner/analysis/mismatched_args.d @@ -8,6 +8,8 @@ import dparse.ast; import dparse.lexer : tok; import dsymbol.builtin.names; + + /// Checks for mismatched argument and parameter names final class MismatchedArgumentCheck : BaseAnalyzer { diff --git a/src/dscanner/analysis/numbers.d b/src/dscanner/analysis/numbers.d index 8e8d55d4..a98af1c0 100644 --- a/src/dscanner/analysis/numbers.d +++ b/src/dscanner/analysis/numbers.d @@ -13,6 +13,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for long and hard-to-read number literals */ diff --git a/src/dscanner/analysis/opequals_without_tohash.d b/src/dscanner/analysis/opequals_without_tohash.d index f3b854d9..180c2ece 100644 --- a/src/dscanner/analysis/opequals_without_tohash.d +++ b/src/dscanner/analysis/opequals_without_tohash.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for when a class/struct has the method opEquals without toHash, or * toHash without opEquals. diff --git a/src/dscanner/analysis/range.d b/src/dscanner/analysis/range.d index f7a6f653..86809cb9 100644 --- a/src/dscanner/analysis/range.d +++ b/src/dscanner/analysis/range.d @@ -12,6 +12,8 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; + + /** * Checks for .. expressions where the left side is larger than the right. This * is almost always a mistake. diff --git a/src/dscanner/analysis/redundant_attributes.d b/src/dscanner/analysis/redundant_attributes.d index 0b3a467f..8ecbc711 100644 --- a/src/dscanner/analysis/redundant_attributes.d +++ b/src/dscanner/analysis/redundant_attributes.d @@ -14,6 +14,8 @@ import std.algorithm; import std.conv : to, text; import std.range : empty, front, walkLength; + + /** * Checks for redundant attributes. At the moment only visibility attributes. */ @@ -277,7 +279,7 @@ unittest assertAnalyzerWarnings(q{ unittest { -@safe: + @safe void foo(); @system { diff --git a/src/dscanner/analysis/redundant_parens.d b/src/dscanner/analysis/redundant_parens.d index 8f2c56ff..c0c394f6 100644 --- a/src/dscanner/analysis/redundant_parens.d +++ b/src/dscanner/analysis/redundant_parens.d @@ -10,6 +10,8 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_ : Scope; + + /** * Checks for redundant parenthesis */ diff --git a/src/dscanner/analysis/run.d b/src/dscanner/analysis/run.d index 83cd7bae..e3f2d348 100644 --- a/src/dscanner/analysis/run.d +++ b/src/dscanner/analysis/run.d @@ -99,6 +99,8 @@ private alias ASTAllocator = CAllocatorImpl!( immutable string defaultErrorFormat = "{filepath}({line}:{column})[{type}]: {message}"; + + void messageFunctionFormat(string format, Message message, bool isError) { auto s = format; @@ -605,4 +607,3 @@ MessageSet analyze(string fileName, const Module m, const StaticAnalysisConfig a return set; } - diff --git a/src/dscanner/analysis/static_if_else.d b/src/dscanner/analysis/static_if_else.d index 17966dab..97b9a96a 100644 --- a/src/dscanner/analysis/static_if_else.d +++ b/src/dscanner/analysis/static_if_else.d @@ -10,6 +10,8 @@ import dparse.lexer; import dscanner.analysis.base; import dscanner.utils : safeAccess; + + /** * Checks for potentially mistaken static if / else if. * @@ -19,7 +21,7 @@ import dscanner.utils : safeAccess; * } else if (bar) { * } * --- - * + * * However, it's more likely that this is a mistake. */ final class StaticIfElse : BaseAnalyzer diff --git a/src/dscanner/analysis/stats_collector.d b/src/dscanner/analysis/stats_collector.d index a2fdee42..4d14ad36 100644 --- a/src/dscanner/analysis/stats_collector.d +++ b/src/dscanner/analysis/stats_collector.d @@ -9,6 +9,8 @@ import dparse.ast; import dparse.lexer; import dscanner.analysis.base; + + final class StatsCollector : BaseAnalyzer { alias visit = ASTVisitor.visit; diff --git a/src/dscanner/analysis/style.d b/src/dscanner/analysis/style.d index 96de04b1..014bed22 100644 --- a/src/dscanner/analysis/style.d +++ b/src/dscanner/analysis/style.d @@ -16,6 +16,8 @@ import dscanner.analysis.helpers; import dscanner.analysis.base; import dsymbol.scope_ : Scope; + + final class StyleChecker : BaseAnalyzer { alias visit = ASTVisitor.visit; diff --git a/src/dscanner/analysis/trust_too_much.d b/src/dscanner/analysis/trust_too_much.d index f9eddf4c..afd3bc48 100644 --- a/src/dscanner/analysis/trust_too_much.d +++ b/src/dscanner/analysis/trust_too_much.d @@ -11,6 +11,8 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; + + /** * Checks that `@trusted` is only applied to a a single function */ diff --git a/src/dscanner/analysis/undocumented.d b/src/dscanner/analysis/undocumented.d index 46e3f76b..c176a2a9 100644 --- a/src/dscanner/analysis/undocumented.d +++ b/src/dscanner/analysis/undocumented.d @@ -13,6 +13,8 @@ import dparse.lexer; import std.regex : ctRegex, matchAll; import std.stdio; + + /** * Checks for undocumented public declarations. Ignores some operator overloads, * main functions, and functions whose name starts with "get" or "set". @@ -265,7 +267,7 @@ private: { assert(isProtection(p)); } - body + do { stack[$ - 1].protection = p; } @@ -275,7 +277,7 @@ private: { assert(isProtection(p)); } - body + do { stack ~= ProtectionInfo(p, false); } @@ -349,4 +351,3 @@ unittest stderr.writeln("Unittest for UndocumentedDeclarationCheck passed."); } - diff --git a/src/dscanner/analysis/unmodified.d b/src/dscanner/analysis/unmodified.d index 7bd9ef3d..3d033224 100644 --- a/src/dscanner/analysis/unmodified.d +++ b/src/dscanner/analysis/unmodified.d @@ -11,6 +11,8 @@ import std.container; import dparse.ast; import dparse.lexer; + + /** * Checks for variables that could have been declared const or immutable */ @@ -382,4 +384,3 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc } }, sac); } - diff --git a/src/dscanner/analysis/unused.d b/src/dscanner/analysis/unused.d index f1d00b61..3914d46d 100644 --- a/src/dscanner/analysis/unused.d +++ b/src/dscanner/analysis/unused.d @@ -12,6 +12,8 @@ import std.regex : Regex, regex, matchAll; import dsymbol.scope_ : Scope; import std.algorithm : all; + + /** * Checks for unused variables. */ diff --git a/src/dscanner/analysis/unused_label.d b/src/dscanner/analysis/unused_label.d index ed028800..20024eea 100644 --- a/src/dscanner/analysis/unused_label.d +++ b/src/dscanner/analysis/unused_label.d @@ -11,6 +11,8 @@ import dparse.lexer; import dsymbol.scope_ : Scope; import std.algorithm.iteration : each; + + /** * Checks for labels that are never used. */ diff --git a/src/dscanner/analysis/unused_result.d b/src/dscanner/analysis/unused_result.d index b1e987bb..a04b8340 100644 --- a/src/dscanner/analysis/unused_result.d +++ b/src/dscanner/analysis/unused_result.d @@ -13,6 +13,8 @@ import dparse.ast, dparse.lexer; import std.algorithm.searching : canFind; import std.range: retro; + + /** * Checks for function call statements which call non-void functions. * @@ -154,4 +156,3 @@ unittest import std.stdio: writeln; writeln("Unittest for UnusedResultChecker passed"); } - diff --git a/src/dscanner/analysis/unused_variable.d b/src/dscanner/analysis/unused_variable.d index e5e67ee5..aa41b719 100644 --- a/src/dscanner/analysis/unused_variable.d +++ b/src/dscanner/analysis/unused_variable.d @@ -10,6 +10,8 @@ import dscanner.analysis.unused; import dsymbol.scope_ : Scope; import std.algorithm.iteration : map; + + /** * Checks for unused variables. */ diff --git a/src/dscanner/analysis/useless_assert.d b/src/dscanner/analysis/useless_assert.d index 0b75ff20..e97cf682 100644 --- a/src/dscanner/analysis/useless_assert.d +++ b/src/dscanner/analysis/useless_assert.d @@ -12,6 +12,8 @@ import dparse.lexer; import std.stdio; + + auto filterChars(string chars, S)(S str) { import std.algorithm.comparison : among; diff --git a/src/dscanner/analysis/useless_initializer.d b/src/dscanner/analysis/useless_initializer.d index 2dc5394a..2b172ac6 100644 --- a/src/dscanner/analysis/useless_initializer.d +++ b/src/dscanner/analysis/useless_initializer.d @@ -14,6 +14,8 @@ import std.algorithm; import std.range : empty; import std.stdio; + + /* Limitations: - Stuff s = Stuff.init does not work with type with postfixes`*` `[]`. @@ -340,4 +342,3 @@ public: stderr.writeln("Unittest for UselessInitializerChecker passed."); } - diff --git a/src/dscanner/analysis/vcall_in_ctor.d b/src/dscanner/analysis/vcall_in_ctor.d index e2a0f6da..20006808 100644 --- a/src/dscanner/analysis/vcall_in_ctor.d +++ b/src/dscanner/analysis/vcall_in_ctor.d @@ -10,6 +10,8 @@ import dparse.ast, dparse.lexer; import std.algorithm.searching : canFind; import std.range: retro; + + /** * Checks virtual calls from the constructor to methods defined in the same class. * @@ -431,4 +433,3 @@ unittest import std.stdio: writeln; writeln("Unittest for VcallCtorChecker passed"); } - diff --git a/src/dscanner/etags.d b/src/dscanner/etags.d index 0d8b2ffc..c62d3a2a 100644 --- a/src/dscanner/etags.d +++ b/src/dscanner/etags.d @@ -36,7 +36,7 @@ version = UseModuleContext; * tagAll = if set, tag private/package declaration too * fileNames = tags will be generated from these files */ -void printEtags(File output, bool tagAll, string[] fileNames) +void printEtags(File output, bool tagAll, string[] fileNames) @trusted { LexerConfig config; StringCache cache = StringCache(StringCache.defaultBucketCount); diff --git a/src/dscanner/highlighter.d b/src/dscanner/highlighter.d index 86860cd7..c64f6905 100644 --- a/src/dscanner/highlighter.d +++ b/src/dscanner/highlighter.d @@ -9,9 +9,12 @@ import std.stdio; import std.array; import dparse.lexer; +@safe: + // http://ethanschoonover.com/solarized void highlight(R)(ref R tokens, string fileName) { + () @trusted { stdout.writeln(q"[ @@ -31,6 +34,7 @@ html { background-color: #fdf6e3; color: #002b36; } .cons { color: #859900; font-weight: bold; }
]");
+    } ();
 
 	while (!tokens.empty)
 	{
@@ -57,17 +61,23 @@ html  { background-color: #fdf6e3; color: #002b36; }
 				// Stupid Windows automatically does a LF → CRLF, so
 				// CRLF → CRCRLF, which is obviously wrong.
 				// Strip out the CR characters here to avoid this.
+                            () @trusted {
 				stdout.write(t.text.replace("<", "<").replace("\r", ""));
+                            } ();
 			}
 			else
+                            () @trusted {
 				stdout.write(t.text.replace("<", "<"));
+                            } ();
 		}
 
 	}
-	stdout.writeln("
\n"); + () @trusted { + stdout.writeln("\n"); + } (); } -void writeSpan(string cssClass, string value) +void writeSpan(string cssClass, string value) @trusted { version (Windows) stdout.write(``, value.replace("&", diff --git a/src/dscanner/main.d b/src/dscanner/main.d index aa28f760..43b2a47b 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -37,12 +37,14 @@ import inifiled; import dsymbol.modulecache; +@safe: + version (unittest) - void main() + void main() @trusted { } else - int main(string[] args) + int main(string[] args) @trusted { bool sloc; bool highlight; @@ -74,48 +76,55 @@ else try { // dfmt off + () @trusted { getopt(args, std.getopt.config.caseSensitive, - "sloc|l", &sloc, - "highlight", &highlight, - "ctags|c", &ctags, - "help|h", &help, - "etags|e", &etags, - "etagsAll", &etagsAll, - "tokenCount|t", &tokenCount, - "syntaxCheck|s", &syntaxCheck, - "ast|xml", &ast, - "imports|i", &imports, - "recursiveImports", &recursiveImports, - "outline|o", &outline, - "tokenDump", &tokenDump, - "styleCheck|S", &styleCheck, - "defaultConfig", &defaultConfig, - "declaration|d", &symbolName, - "config", &configLocation, - "report", &report, - "reportFormat", &reportFormat, - "reportFile", &reportFile, - "I", &importPaths, - "version", &printVersion, - "muffinButton", &muffin, - "explore", &explore, - "skipTests", &skipTests, - "errorFormat|f", &errorFormat); + "sloc|l", &sloc, + "highlight", &highlight, + "ctags|c", &ctags, + "help|h", &help, + "etags|e", &etags, + "etagsAll", &etagsAll, + "tokenCount|t", &tokenCount, + "syntaxCheck|s", &syntaxCheck, + "ast|xml", &ast, + "imports|i", &imports, + "recursiveImports", &recursiveImports, + "outline|o", &outline, + "tokenDump", &tokenDump, + "styleCheck|S", &styleCheck, + "defaultConfig", &defaultConfig, + "declaration|d", &symbolName, + "config", &configLocation, + "report", &report, + "reportFormat", &reportFormat, + "reportFile", &reportFile, + "I", &importPaths, + "version", &printVersion, + "muffinButton", &muffin, + "explore", &explore, + "skipTests", &skipTests, + "errorFormat|f", &errorFormat); + } (); //dfmt on } catch (ConvException e) { - stderr.writeln(e.msg); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } catch (GetOptException e) { - stderr.writeln(e.msg); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } if (muffin) { + () @trusted { stdout.writeln(` ___________ __(#*O 0** @%*)__ _(%*o#*O%*0 #O#%##@)_ @@ -125,13 +134,16 @@ else |I|I|I|I|I|I|I|I|I|I| |I|I|I|I|I|I|I|I|I|I| |I|I|I|I|I|I|I|I|I|I|`); + } (); return 0; } if (explore) { - stdout.writeln("D-Scanner: Scanning..."); + () @trusted { + stdout.writeln("D-Scanner: Scanning..."); stderr.writeln("D-Scanner: No new astronomical objects discovered."); + } (); return 1; } @@ -153,7 +165,7 @@ else const(string[]) absImportPaths = importPaths.map!(a => a.absolutePath() .buildNormalizedPath()).array(); - auto alloc = scoped!(dsymbol.modulecache.ASTAllocator)(); + scope alloc = () @trusted { return new dsymbol.modulecache.ASTAllocator(); } (); auto moduleCache = ModuleCache(alloc); if (absImportPaths.length) @@ -328,7 +340,7 @@ else return 0; } -void printHelp(string programName) +void printHelp(string programName) @trusted { stderr.writefln(` Usage: %s diff --git a/src/dscanner/reports.d b/src/dscanner/reports.d index 3e0c9b79..8a98ebd2 100644 --- a/src/dscanner/reports.d +++ b/src/dscanner/reports.d @@ -12,6 +12,8 @@ import std.array : split, array, Appender, appender; import dscanner.analysis.base : Message, MessageSet; import dscanner.analysis.stats_collector; +@safe: + class DScannerJsonReporter { struct Issue @@ -146,7 +148,7 @@ class SonarQubeGenericIssueDataReporter { _issues ~= toIssues(messageSet); } - + void addMessage(Message message, bool isError = false) { _issues ~= toIssue(message, isError); @@ -185,7 +187,7 @@ class SonarQubeGenericIssueDataReporter } private static Issue toIssue(Message message, bool isError = false) - { + { // dfmt off Issue issue = { engineId: "dscanner", @@ -242,4 +244,4 @@ class SonarQubeGenericIssueDataReporter } } } -} \ No newline at end of file +} diff --git a/src/dscanner/stats.d b/src/dscanner/stats.d index af014f45..de75539f 100644 --- a/src/dscanner/stats.d +++ b/src/dscanner/stats.d @@ -9,6 +9,8 @@ import std.stdio; import std.algorithm; import dparse.lexer; +@safe: + pure nothrow bool isLineOfCode(IdType t) { switch (t) diff --git a/src/dscanner/symbol_finder.d b/src/dscanner/symbol_finder.d index 16e2e866..efb0b775 100644 --- a/src/dscanner/symbol_finder.d +++ b/src/dscanner/symbol_finder.d @@ -14,6 +14,8 @@ import std.stdio; import std.file : isFile; import std.functional : toDelegate; +@safe: + void findDeclarationOf(File output, string symbolName, string[] fileNames) { findDeclarationOf((string fileName, size_t line, size_t column) @@ -30,7 +32,7 @@ alias OutputHandler = void delegate(string fileName, size_t line, size_t column) /// output = Callback which gets called when a declaration is found /// symbolName = Symbol name to search for /// fileNames = An array of file names which might contain stdin to read from stdin -void findDeclarationOf(scope OutputHandler output, string symbolName, string[] fileNames) +void findDeclarationOf(scope OutputHandler output, string symbolName, string[] fileNames) @trusted { import std.array : uninitializedArray, array; import std.conv : to; @@ -136,7 +138,7 @@ class FinderVisitor : ASTVisitor { if (t.name.text == symbolName) output(fileName, t.name.line, t.name.column); - t.accept(this); + () @trusted { t.accept(this); } (); } } diff --git a/src/dscanner/utils.d b/src/dscanner/utils.d index 4c7edb7d..00f24401 100644 --- a/src/dscanner/utils.d +++ b/src/dscanner/utils.d @@ -7,6 +7,8 @@ import std.encoding : BOM, BOMSeq, EncodingException, getBOM; import std.format : format; import std.file : exists, read; +@safe: + private void processBOM(ref ubyte[] sourceCode, string fname) { enum spec = "D-Scanner does not support %s-encoded files (%s)"; @@ -54,7 +56,7 @@ ubyte[] readStdin() ubyte[4096] buf; while (true) { - auto b = stdin.rawRead(buf); + auto b = () @trusted { return stdin.rawRead(buf); } (); if (b.length == 0) break; sourceCode.put(b); @@ -70,12 +72,12 @@ ubyte[] readFile(string fileName) return readStdin(); if (!exists(fileName)) { - stderr.writefln("%s does not exist", fileName); + () @trusted { stderr.writefln("%s does not exist", fileName); } (); return []; } File f = File(fileName); ubyte[] sourceCode; - sourceCode = cast(ubyte[]) fileName.read(); + () @trusted { sourceCode = cast(ubyte[]) fileName.read(); } (); sourceCode.processBOM(fileName); return sourceCode; } @@ -104,13 +106,15 @@ string[] expandArgs(string[] args) if (arg == "stdin" || isFileSafe(arg)) rVal ~= arg; else + () @trusted { foreach (item; dirEntries(arg, SpanMode.breadth).map!(a => a.name)) - { + { if (isFileSafe(item) && (item.endsWith(`.d`) || item.endsWith(`.di`)) && !item.canFind(dirSeparator ~ '.')) - rVal ~= item; + rVal ~= item; else - continue; - } + continue; + } + } (); } return rVal; } From e952076e1da93c7cdfaf2b6690c0b1f9076486ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Wed, 18 Aug 2021 23:47:55 +0200 Subject: [PATCH 02/16] Bump dsymbol dep --- dsymbol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsymbol b/dsymbol index aa4db35b..91049f94 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit aa4db35bee875a3c937cdd78b7f2e8c3a475fe79 +Subproject commit 91049f945b1317335f9382ef341d903e5a5e20c9 From 542a122756cb0fe6f71d4a3386659c9657878818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Fri, 20 Aug 2021 00:24:09 +0200 Subject: [PATCH 03/16] Bump dsymbol --- dsymbol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsymbol b/dsymbol index 91049f94..aaed94da 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit 91049f945b1317335f9382ef341d903e5a5e20c9 +Subproject commit aaed94dad161218fae260759cc1332911e8a8a37 From 2395c38c32236abd01c7a3f4d08d052de7dde568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Fri, 20 Aug 2021 19:47:05 +0200 Subject: [PATCH 04/16] Adjust makefile debug target --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index b4d5a3b1..3dc0cd3f 100644 --- a/makefile +++ b/makefile @@ -46,7 +46,7 @@ githash: mkdir -p bin && ${GIT} describe --tags > bin/githash.txt debug: githash - ${DC} -w -g -Jbin -ofdsc ${VERSIONS} ${DEBUG_VERSIONS} ${INCLUDE_PATHS} ${SRC} + ${DC} -w -g -debug -Jbin -ofdsc ${VERSIONS} ${DEBUG_VERSIONS} ${INCLUDE_PATHS} ${SRC} dmdbuild: githash ${DC} ${DMD_FLAGS} -ofbin/dscanner ${VERSIONS} ${INCLUDE_PATHS} ${SRC} From 1b759da811a81344df9fd8f1db9fd512f7a388e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Fri, 20 Aug 2021 19:57:14 +0200 Subject: [PATCH 05/16] Revert changes to makefile --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 3dc0cd3f..b4d5a3b1 100644 --- a/makefile +++ b/makefile @@ -46,7 +46,7 @@ githash: mkdir -p bin && ${GIT} describe --tags > bin/githash.txt debug: githash - ${DC} -w -g -debug -Jbin -ofdsc ${VERSIONS} ${DEBUG_VERSIONS} ${INCLUDE_PATHS} ${SRC} + ${DC} -w -g -Jbin -ofdsc ${VERSIONS} ${DEBUG_VERSIONS} ${INCLUDE_PATHS} ${SRC} dmdbuild: githash ${DC} ${DMD_FLAGS} -ofbin/dscanner ${VERSIONS} ${INCLUDE_PATHS} ${SRC} From 51eda854ca78ea8dd966e69ec12ccc8905c7e3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Fri, 20 Aug 2021 19:58:06 +0200 Subject: [PATCH 06/16] Bump dsymbol --- dsymbol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsymbol b/dsymbol index aaed94da..2d599905 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit aaed94dad161218fae260759cc1332911e8a8a37 +Subproject commit 2d599905eced19329e5147ffaaec532d28410cd5 From 2601b1560170d5d3cd58d0342a4cc7fe3b43e86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:00:56 +0200 Subject: [PATCH 07/16] Revert whitespace changes --- src/dscanner/analysis/allman.d | 1 - src/dscanner/analysis/asm_style.d | 2 -- src/dscanner/analysis/assert_without_msg.d | 2 -- src/dscanner/analysis/auto_function.d | 2 -- src/dscanner/analysis/auto_ref_assignment.d | 2 -- src/dscanner/analysis/base.d | 2 -- src/dscanner/analysis/builtin_property_names.d | 2 -- src/dscanner/analysis/comma_expression.d | 2 -- src/dscanner/analysis/config.d | 2 -- src/dscanner/analysis/constructors.d | 2 -- src/dscanner/analysis/del.d | 2 -- src/dscanner/analysis/duplicate_attribute.d | 2 -- src/dscanner/analysis/enumarrayliteral.d | 2 -- src/dscanner/analysis/final_attribute.d | 2 -- src/dscanner/analysis/fish.d | 2 -- src/dscanner/analysis/has_public_example.d | 3 +-- src/dscanner/analysis/helpers.d | 2 -- src/dscanner/analysis/if_constraints_indent.d | 2 -- src/dscanner/analysis/if_statements.d | 2 -- src/dscanner/analysis/ifelsesame.d | 2 -- src/dscanner/analysis/imports_sortedness.d | 2 -- src/dscanner/analysis/incorrect_infinite_range.d | 2 -- src/dscanner/analysis/label_var_same_name_check.d | 2 -- src/dscanner/analysis/lambda_return_check.d | 2 -- src/dscanner/analysis/length_subtraction.d | 2 -- src/dscanner/analysis/line_length.d | 2 -- src/dscanner/analysis/local_imports.d | 2 -- src/dscanner/analysis/logic_precedence.d | 2 -- src/dscanner/analysis/mismatched_args.d | 2 -- src/dscanner/analysis/numbers.d | 2 -- src/dscanner/analysis/opequals_without_tohash.d | 2 -- src/dscanner/analysis/range.d | 2 -- src/dscanner/analysis/redundant_attributes.d | 2 -- src/dscanner/analysis/redundant_parens.d | 2 -- src/dscanner/analysis/run.d | 3 +-- src/dscanner/analysis/static_if_else.d | 4 +--- src/dscanner/analysis/stats_collector.d | 2 -- src/dscanner/analysis/style.d | 2 -- src/dscanner/analysis/trust_too_much.d | 2 -- src/dscanner/analysis/unmodified.d | 3 +-- src/dscanner/analysis/unused.d | 2 -- src/dscanner/analysis/unused_label.d | 2 -- src/dscanner/analysis/unused_result.d | 3 +-- src/dscanner/analysis/unused_variable.d | 2 -- src/dscanner/analysis/useless_assert.d | 2 -- src/dscanner/analysis/useless_initializer.d | 3 +-- src/dscanner/analysis/vcall_in_ctor.d | 3 +-- 47 files changed, 7 insertions(+), 94 deletions(-) diff --git a/src/dscanner/analysis/allman.d b/src/dscanner/analysis/allman.d index dea1473c..2cbd9ccc 100644 --- a/src/dscanner/analysis/allman.d +++ b/src/dscanner/analysis/allman.d @@ -12,7 +12,6 @@ import dsymbol.scope_ : Scope; import std.algorithm; import std.range; - /** Checks for the allman style (braces should be on their own line) ------------ diff --git a/src/dscanner/analysis/asm_style.d b/src/dscanner/analysis/asm_style.d index 68dc1f57..de54c773 100644 --- a/src/dscanner/analysis/asm_style.d +++ b/src/dscanner/analysis/asm_style.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for confusing asm expressions. * See_also: $(LINK https://issues.dlang.org/show_bug.cgi?id=9738) diff --git a/src/dscanner/analysis/assert_without_msg.d b/src/dscanner/analysis/assert_without_msg.d index 2447ede7..e24c9891 100644 --- a/src/dscanner/analysis/assert_without_msg.d +++ b/src/dscanner/analysis/assert_without_msg.d @@ -13,8 +13,6 @@ import dparse.ast; import std.stdio; import std.algorithm; - - /** * Check that all asserts have an explanatory message. */ diff --git a/src/dscanner/analysis/auto_function.d b/src/dscanner/analysis/auto_function.d index f8853a01..659dbff5 100644 --- a/src/dscanner/analysis/auto_function.d +++ b/src/dscanner/analysis/auto_function.d @@ -13,8 +13,6 @@ import dparse.lexer; import std.stdio; import std.algorithm.searching : any; - - /** * Checks for auto functions without return statement. * diff --git a/src/dscanner/analysis/auto_ref_assignment.d b/src/dscanner/analysis/auto_ref_assignment.d index 7c1b9dc6..dbd57609 100644 --- a/src/dscanner/analysis/auto_ref_assignment.d +++ b/src/dscanner/analysis/auto_ref_assignment.d @@ -9,8 +9,6 @@ import dparse.lexer; import dparse.ast; import dscanner.analysis.base; - - /** * Checks for assignment to auto-ref function parameters. */ diff --git a/src/dscanner/analysis/base.d b/src/dscanner/analysis/base.d index fbd15f04..d7c7e96b 100644 --- a/src/dscanner/analysis/base.d +++ b/src/dscanner/analysis/base.d @@ -6,8 +6,6 @@ import dparse.ast; import std.array; import dsymbol.scope_ : Scope; - - struct Message { /// Name of the file where the warning was triggered diff --git a/src/dscanner/analysis/builtin_property_names.d b/src/dscanner/analysis/builtin_property_names.d index 6f7148a8..cadc2209 100644 --- a/src/dscanner/analysis/builtin_property_names.d +++ b/src/dscanner/analysis/builtin_property_names.d @@ -14,8 +14,6 @@ import dscanner.analysis.helpers; import dsymbol.scope_; import std.algorithm : map; - - /** * The following code should be killed with fire: * --- diff --git a/src/dscanner/analysis/comma_expression.d b/src/dscanner/analysis/comma_expression.d index eed64939..45c7d683 100644 --- a/src/dscanner/analysis/comma_expression.d +++ b/src/dscanner/analysis/comma_expression.d @@ -10,8 +10,6 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; - - /** * Check for uses of the comma expression. */ diff --git a/src/dscanner/analysis/config.d b/src/dscanner/analysis/config.d index 29337f40..c917e66e 100644 --- a/src/dscanner/analysis/config.d +++ b/src/dscanner/analysis/config.d @@ -7,8 +7,6 @@ module dscanner.analysis.config; import inifiled; - - /// Returns: A default configuration. StaticAnalysisConfig defaultStaticAnalysisConfig() { diff --git a/src/dscanner/analysis/constructors.d b/src/dscanner/analysis/constructors.d index dedbd0b2..2a65e069 100644 --- a/src/dscanner/analysis/constructors.d +++ b/src/dscanner/analysis/constructors.d @@ -7,8 +7,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - final class ConstructorCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/del.d b/src/dscanner/analysis/del.d index 81b4d60c..99ca6408 100644 --- a/src/dscanner/analysis/del.d +++ b/src/dscanner/analysis/del.d @@ -11,8 +11,6 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; - - /** * Checks for use of the deprecated 'delete' keyword */ diff --git a/src/dscanner/analysis/duplicate_attribute.d b/src/dscanner/analysis/duplicate_attribute.d index 7585c02a..539da980 100644 --- a/src/dscanner/analysis/duplicate_attribute.d +++ b/src/dscanner/analysis/duplicate_attribute.d @@ -13,8 +13,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for duplicate attributes such as @property, @safe, * @trusted, @system, pure, and nothrow diff --git a/src/dscanner/analysis/enumarrayliteral.d b/src/dscanner/analysis/enumarrayliteral.d index 3b88b86b..94f898a1 100644 --- a/src/dscanner/analysis/enumarrayliteral.d +++ b/src/dscanner/analysis/enumarrayliteral.d @@ -11,8 +11,6 @@ import dscanner.analysis.base; import std.algorithm : canFind, map; import dsymbol.scope_ : Scope; - - void doNothing(string, size_t, size_t, string, bool) { } diff --git a/src/dscanner/analysis/final_attribute.d b/src/dscanner/analysis/final_attribute.d index 57549a15..8df2adbf 100644 --- a/src/dscanner/analysis/final_attribute.d +++ b/src/dscanner/analysis/final_attribute.d @@ -10,8 +10,6 @@ import dscanner.analysis.helpers; import dparse.ast; import dparse.lexer; - - /** * Checks for useless usage of the final attribute. * diff --git a/src/dscanner/analysis/fish.d b/src/dscanner/analysis/fish.d index 7cbf987d..0417e486 100644 --- a/src/dscanner/analysis/fish.d +++ b/src/dscanner/analysis/fish.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for use of the deprecated floating point comparison operators. */ diff --git a/src/dscanner/analysis/has_public_example.d b/src/dscanner/analysis/has_public_example.d index ffeeb5d1..0d82977e 100644 --- a/src/dscanner/analysis/has_public_example.d +++ b/src/dscanner/analysis/has_public_example.d @@ -12,8 +12,6 @@ import dparse.lexer; import std.algorithm; import std.stdio; - - /** * Checks for public declarations without a documented unittests. * For now, variable and enum declarations aren't checked. @@ -334,3 +332,4 @@ unittest stderr.writeln("Unittest for HasPublicExampleCheck passed."); } + diff --git a/src/dscanner/analysis/helpers.d b/src/dscanner/analysis/helpers.d index 5240946d..98c817b4 100644 --- a/src/dscanner/analysis/helpers.d +++ b/src/dscanner/analysis/helpers.d @@ -19,8 +19,6 @@ import dscanner.analysis.base; import stdx.allocator.mallocator; import stdx.allocator; - - S between(S)(S value, S before, S after) if (isSomeString!S) { return value.after(before).before(after); diff --git a/src/dscanner/analysis/if_constraints_indent.d b/src/dscanner/analysis/if_constraints_indent.d index e12d1042..9757c07a 100644 --- a/src/dscanner/analysis/if_constraints_indent.d +++ b/src/dscanner/analysis/if_constraints_indent.d @@ -12,8 +12,6 @@ import dsymbol.scope_ : Scope; import std.algorithm.iteration : filter; import std.range; - - /** Checks whether all if constraints have the same indention as their declaration. */ diff --git a/src/dscanner/analysis/if_statements.d b/src/dscanner/analysis/if_statements.d index 86f4feb5..a70aec5d 100644 --- a/src/dscanner/analysis/if_statements.d +++ b/src/dscanner/analysis/if_statements.d @@ -10,8 +10,6 @@ import dparse.formatter; import dscanner.analysis.base; import dsymbol.scope_ : Scope; - - final class IfStatementCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/ifelsesame.d b/src/dscanner/analysis/ifelsesame.d index 32fc6a41..e757b91d 100644 --- a/src/dscanner/analysis/ifelsesame.d +++ b/src/dscanner/analysis/ifelsesame.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for duplicated code in conditional and logical expressions. * $(UL diff --git a/src/dscanner/analysis/imports_sortedness.d b/src/dscanner/analysis/imports_sortedness.d index b14c1e47..4f33fd4b 100644 --- a/src/dscanner/analysis/imports_sortedness.d +++ b/src/dscanner/analysis/imports_sortedness.d @@ -10,8 +10,6 @@ import dparse.ast; import std.stdio; - - /** * Checks the sortedness of module imports */ diff --git a/src/dscanner/analysis/incorrect_infinite_range.d b/src/dscanner/analysis/incorrect_infinite_range.d index 5990639f..1df6b3e0 100644 --- a/src/dscanner/analysis/incorrect_infinite_range.d +++ b/src/dscanner/analysis/incorrect_infinite_range.d @@ -10,8 +10,6 @@ import dscanner.analysis.helpers; import dparse.ast; import dparse.lexer; - - /** * Checks for incorrect infinite range definitions */ diff --git a/src/dscanner/analysis/label_var_same_name_check.d b/src/dscanner/analysis/label_var_same_name_check.d index b293e024..dc85bdb6 100644 --- a/src/dscanner/analysis/label_var_same_name_check.d +++ b/src/dscanner/analysis/label_var_same_name_check.d @@ -10,8 +10,6 @@ import dsymbol.scope_ : Scope; import dscanner.analysis.base; import dscanner.analysis.helpers; - - /** * Checks for labels and variables that have the same name. */ diff --git a/src/dscanner/analysis/lambda_return_check.d b/src/dscanner/analysis/lambda_return_check.d index 6cdba625..e0b0b473 100644 --- a/src/dscanner/analysis/lambda_return_check.d +++ b/src/dscanner/analysis/lambda_return_check.d @@ -10,8 +10,6 @@ import dparse.lexer; import dscanner.analysis.base; import dscanner.utils : safeAccess; - - final class LambdaReturnCheck : BaseAnalyzer { alias visit = BaseAnalyzer.visit; diff --git a/src/dscanner/analysis/length_subtraction.d b/src/dscanner/analysis/length_subtraction.d index a07a13a4..a788ec76 100644 --- a/src/dscanner/analysis/length_subtraction.d +++ b/src/dscanner/analysis/length_subtraction.d @@ -13,8 +13,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; - - /** * Checks for subtraction from a .length property. This is usually a bug. */ diff --git a/src/dscanner/analysis/line_length.d b/src/dscanner/analysis/line_length.d index 1c3b1113..f10c3d2e 100644 --- a/src/dscanner/analysis/line_length.d +++ b/src/dscanner/analysis/line_length.d @@ -12,8 +12,6 @@ import dparse.lexer; import std.typecons : tuple, Tuple; - - /** * Checks for lines longer than 120 characters */ diff --git a/src/dscanner/analysis/local_imports.d b/src/dscanner/analysis/local_imports.d index 6e342e84..4489ce7d 100644 --- a/src/dscanner/analysis/local_imports.d +++ b/src/dscanner/analysis/local_imports.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; - - /** * Checks for local imports that import all symbols. * See_also: $(LINK https://issues.dlang.org/show_bug.cgi?id=10378) diff --git a/src/dscanner/analysis/logic_precedence.d b/src/dscanner/analysis/logic_precedence.d index d6bf1194..35d36338 100644 --- a/src/dscanner/analysis/logic_precedence.d +++ b/src/dscanner/analysis/logic_precedence.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_; - - /** * Checks for code with confusing && and || operator precedence * --- diff --git a/src/dscanner/analysis/mismatched_args.d b/src/dscanner/analysis/mismatched_args.d index 2a5e2b16..a25ce0e5 100644 --- a/src/dscanner/analysis/mismatched_args.d +++ b/src/dscanner/analysis/mismatched_args.d @@ -8,8 +8,6 @@ import dparse.ast; import dparse.lexer : tok; import dsymbol.builtin.names; - - /// Checks for mismatched argument and parameter names final class MismatchedArgumentCheck : BaseAnalyzer { diff --git a/src/dscanner/analysis/numbers.d b/src/dscanner/analysis/numbers.d index a98af1c0..8e8d55d4 100644 --- a/src/dscanner/analysis/numbers.d +++ b/src/dscanner/analysis/numbers.d @@ -13,8 +13,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for long and hard-to-read number literals */ diff --git a/src/dscanner/analysis/opequals_without_tohash.d b/src/dscanner/analysis/opequals_without_tohash.d index 180c2ece..f3b854d9 100644 --- a/src/dscanner/analysis/opequals_without_tohash.d +++ b/src/dscanner/analysis/opequals_without_tohash.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for when a class/struct has the method opEquals without toHash, or * toHash without opEquals. diff --git a/src/dscanner/analysis/range.d b/src/dscanner/analysis/range.d index 86809cb9..f7a6f653 100644 --- a/src/dscanner/analysis/range.d +++ b/src/dscanner/analysis/range.d @@ -12,8 +12,6 @@ import dscanner.analysis.base; import dscanner.analysis.helpers; import dsymbol.scope_ : Scope; - - /** * Checks for .. expressions where the left side is larger than the right. This * is almost always a mistake. diff --git a/src/dscanner/analysis/redundant_attributes.d b/src/dscanner/analysis/redundant_attributes.d index 8ecbc711..caf04c08 100644 --- a/src/dscanner/analysis/redundant_attributes.d +++ b/src/dscanner/analysis/redundant_attributes.d @@ -14,8 +14,6 @@ import std.algorithm; import std.conv : to, text; import std.range : empty, front, walkLength; - - /** * Checks for redundant attributes. At the moment only visibility attributes. */ diff --git a/src/dscanner/analysis/redundant_parens.d b/src/dscanner/analysis/redundant_parens.d index c0c394f6..8f2c56ff 100644 --- a/src/dscanner/analysis/redundant_parens.d +++ b/src/dscanner/analysis/redundant_parens.d @@ -10,8 +10,6 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_ : Scope; - - /** * Checks for redundant parenthesis */ diff --git a/src/dscanner/analysis/run.d b/src/dscanner/analysis/run.d index e3f2d348..83cd7bae 100644 --- a/src/dscanner/analysis/run.d +++ b/src/dscanner/analysis/run.d @@ -99,8 +99,6 @@ private alias ASTAllocator = CAllocatorImpl!( immutable string defaultErrorFormat = "{filepath}({line}:{column})[{type}]: {message}"; - - void messageFunctionFormat(string format, Message message, bool isError) { auto s = format; @@ -607,3 +605,4 @@ MessageSet analyze(string fileName, const Module m, const StaticAnalysisConfig a return set; } + diff --git a/src/dscanner/analysis/static_if_else.d b/src/dscanner/analysis/static_if_else.d index 97b9a96a..17966dab 100644 --- a/src/dscanner/analysis/static_if_else.d +++ b/src/dscanner/analysis/static_if_else.d @@ -10,8 +10,6 @@ import dparse.lexer; import dscanner.analysis.base; import dscanner.utils : safeAccess; - - /** * Checks for potentially mistaken static if / else if. * @@ -21,7 +19,7 @@ import dscanner.utils : safeAccess; * } else if (bar) { * } * --- - * + * * However, it's more likely that this is a mistake. */ final class StaticIfElse : BaseAnalyzer diff --git a/src/dscanner/analysis/stats_collector.d b/src/dscanner/analysis/stats_collector.d index 4d14ad36..a2fdee42 100644 --- a/src/dscanner/analysis/stats_collector.d +++ b/src/dscanner/analysis/stats_collector.d @@ -9,8 +9,6 @@ import dparse.ast; import dparse.lexer; import dscanner.analysis.base; - - final class StatsCollector : BaseAnalyzer { alias visit = ASTVisitor.visit; diff --git a/src/dscanner/analysis/style.d b/src/dscanner/analysis/style.d index 014bed22..96de04b1 100644 --- a/src/dscanner/analysis/style.d +++ b/src/dscanner/analysis/style.d @@ -16,8 +16,6 @@ import dscanner.analysis.helpers; import dscanner.analysis.base; import dsymbol.scope_ : Scope; - - final class StyleChecker : BaseAnalyzer { alias visit = ASTVisitor.visit; diff --git a/src/dscanner/analysis/trust_too_much.d b/src/dscanner/analysis/trust_too_much.d index afd3bc48..f9eddf4c 100644 --- a/src/dscanner/analysis/trust_too_much.d +++ b/src/dscanner/analysis/trust_too_much.d @@ -11,8 +11,6 @@ import dparse.lexer; import dscanner.analysis.base; import dsymbol.scope_; - - /** * Checks that `@trusted` is only applied to a a single function */ diff --git a/src/dscanner/analysis/unmodified.d b/src/dscanner/analysis/unmodified.d index 3d033224..7bd9ef3d 100644 --- a/src/dscanner/analysis/unmodified.d +++ b/src/dscanner/analysis/unmodified.d @@ -11,8 +11,6 @@ import std.container; import dparse.ast; import dparse.lexer; - - /** * Checks for variables that could have been declared const or immutable */ @@ -384,3 +382,4 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc } }, sac); } + diff --git a/src/dscanner/analysis/unused.d b/src/dscanner/analysis/unused.d index 3914d46d..f1d00b61 100644 --- a/src/dscanner/analysis/unused.d +++ b/src/dscanner/analysis/unused.d @@ -12,8 +12,6 @@ import std.regex : Regex, regex, matchAll; import dsymbol.scope_ : Scope; import std.algorithm : all; - - /** * Checks for unused variables. */ diff --git a/src/dscanner/analysis/unused_label.d b/src/dscanner/analysis/unused_label.d index 20024eea..ed028800 100644 --- a/src/dscanner/analysis/unused_label.d +++ b/src/dscanner/analysis/unused_label.d @@ -11,8 +11,6 @@ import dparse.lexer; import dsymbol.scope_ : Scope; import std.algorithm.iteration : each; - - /** * Checks for labels that are never used. */ diff --git a/src/dscanner/analysis/unused_result.d b/src/dscanner/analysis/unused_result.d index a04b8340..b1e987bb 100644 --- a/src/dscanner/analysis/unused_result.d +++ b/src/dscanner/analysis/unused_result.d @@ -13,8 +13,6 @@ import dparse.ast, dparse.lexer; import std.algorithm.searching : canFind; import std.range: retro; - - /** * Checks for function call statements which call non-void functions. * @@ -156,3 +154,4 @@ unittest import std.stdio: writeln; writeln("Unittest for UnusedResultChecker passed"); } + diff --git a/src/dscanner/analysis/unused_variable.d b/src/dscanner/analysis/unused_variable.d index aa41b719..e5e67ee5 100644 --- a/src/dscanner/analysis/unused_variable.d +++ b/src/dscanner/analysis/unused_variable.d @@ -10,8 +10,6 @@ import dscanner.analysis.unused; import dsymbol.scope_ : Scope; import std.algorithm.iteration : map; - - /** * Checks for unused variables. */ diff --git a/src/dscanner/analysis/useless_assert.d b/src/dscanner/analysis/useless_assert.d index e97cf682..0b75ff20 100644 --- a/src/dscanner/analysis/useless_assert.d +++ b/src/dscanner/analysis/useless_assert.d @@ -12,8 +12,6 @@ import dparse.lexer; import std.stdio; - - auto filterChars(string chars, S)(S str) { import std.algorithm.comparison : among; diff --git a/src/dscanner/analysis/useless_initializer.d b/src/dscanner/analysis/useless_initializer.d index 2b172ac6..2dc5394a 100644 --- a/src/dscanner/analysis/useless_initializer.d +++ b/src/dscanner/analysis/useless_initializer.d @@ -14,8 +14,6 @@ import std.algorithm; import std.range : empty; import std.stdio; - - /* Limitations: - Stuff s = Stuff.init does not work with type with postfixes`*` `[]`. @@ -342,3 +340,4 @@ public: stderr.writeln("Unittest for UselessInitializerChecker passed."); } + diff --git a/src/dscanner/analysis/vcall_in_ctor.d b/src/dscanner/analysis/vcall_in_ctor.d index 20006808..e2a0f6da 100644 --- a/src/dscanner/analysis/vcall_in_ctor.d +++ b/src/dscanner/analysis/vcall_in_ctor.d @@ -10,8 +10,6 @@ import dparse.ast, dparse.lexer; import std.algorithm.searching : canFind; import std.range: retro; - - /** * Checks virtual calls from the constructor to methods defined in the same class. * @@ -433,3 +431,4 @@ unittest import std.stdio: writeln; writeln("Unittest for VcallCtorChecker passed"); } + From 815dcad5be734f9218f115225eff9f87a1543a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:20:08 +0200 Subject: [PATCH 08/16] Revert changes to makefile --- makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index b4d5a3b1..20b9801d 100644 --- a/makefile +++ b/makefile @@ -27,14 +27,13 @@ INCLUDE_PATHS = \ -Ilibddoc/common/source \ -Istdx-allocator/source VERSIONS = -DEBUG_VERSIONS = -version=StdLoggerDisableWarning -# DEBUG_VERSIONS = -version=StdLoggerDisableWarning -DMD_FLAGS = -w -g -Jbin -od${OBJ_DIR} -version=StdLoggerDisableWarning +DEBUG_VERSIONS = -version=dparse_verbose +DMD_FLAGS = -w -release -O -Jbin -od${OBJ_DIR} -version=StdLoggerDisableWarning override DMD_FLAGS += $(DFLAGS) override LDC_FLAGS += $(DFLAGS) override GDC_FLAGS += $(DFLAGS) DMD_TEST_FLAGS = -w -g -Jbin -version=StdLoggerDisableWarning -override LDC_FLAGS += --d-debug -g -oq -d-version=StdLoggerDisableWarning -fsanitize=address -link-defaultlib-debug +override LDC_FLAGS += -O5 -release -oq -d-version=StdLoggerDisableWarning override GDC_FLAGS += -O3 -frelease -d-version=StdLoggerDisableWarning SHELL:=/usr/bin/env bash From 9454a1c85938e77c86ebe1aa1a58f6a58d996920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:22:33 +0200 Subject: [PATCH 09/16] Replace spaces with tabs --- src/dscanner/analysis/base.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dscanner/analysis/base.d b/src/dscanner/analysis/base.d index d7c7e96b..d6e8b144 100644 --- a/src/dscanner/analysis/base.d +++ b/src/dscanner/analysis/base.d @@ -81,7 +81,7 @@ protected: override void visit(const T structDec) { inAggregate = true; - () @trusted { structDec.accept(this); } (); + () @trusted { structDec.accept(this); } (); inAggregate = false; } } From 8be0e0432b74fecd29c08f4596d1f52fd312d686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:23:04 +0200 Subject: [PATCH 10/16] Replace spaces with tabs --- src/dscanner/analysis/enumarrayliteral.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dscanner/analysis/enumarrayliteral.d b/src/dscanner/analysis/enumarrayliteral.d index 94f898a1..1335a964 100644 --- a/src/dscanner/analysis/enumarrayliteral.d +++ b/src/dscanner/analysis/enumarrayliteral.d @@ -52,6 +52,6 @@ final class EnumArrayLiteralCheck : BaseAnalyzer ~ part.identifier.text ~ " = [ ...' instead."); } } - () @trusted { autoDec.accept(this); } (); + () @trusted { autoDec.accept(this); } (); } } From 3a819da6832d55206e5c83e69ba37b790a6f8b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:23:25 +0200 Subject: [PATCH 11/16] Remove spaces --- src/dscanner/analysis/undocumented.d | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/dscanner/analysis/undocumented.d b/src/dscanner/analysis/undocumented.d index c176a2a9..36551d16 100644 --- a/src/dscanner/analysis/undocumented.d +++ b/src/dscanner/analysis/undocumented.d @@ -13,8 +13,6 @@ import dparse.lexer; import std.regex : ctRegex, matchAll; import std.stdio; - - /** * Checks for undocumented public declarations. Ignores some operator overloads, * main functions, and functions whose name starts with "get" or "set". From 9f42e54e4a7ff8d32f3c872d0b7c1ab362a8ba50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:25:11 +0200 Subject: [PATCH 12/16] Use more tabs --- src/dscanner/main.d | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/dscanner/main.d b/src/dscanner/main.d index 43b2a47b..6905864b 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -78,33 +78,33 @@ else // dfmt off () @trusted { getopt(args, std.getopt.config.caseSensitive, - "sloc|l", &sloc, - "highlight", &highlight, - "ctags|c", &ctags, - "help|h", &help, - "etags|e", &etags, - "etagsAll", &etagsAll, - "tokenCount|t", &tokenCount, - "syntaxCheck|s", &syntaxCheck, - "ast|xml", &ast, - "imports|i", &imports, - "recursiveImports", &recursiveImports, - "outline|o", &outline, - "tokenDump", &tokenDump, - "styleCheck|S", &styleCheck, - "defaultConfig", &defaultConfig, - "declaration|d", &symbolName, - "config", &configLocation, - "report", &report, - "reportFormat", &reportFormat, - "reportFile", &reportFile, - "I", &importPaths, - "version", &printVersion, - "muffinButton", &muffin, - "explore", &explore, - "skipTests", &skipTests, - "errorFormat|f", &errorFormat); - } (); + "sloc|l", &sloc, + "highlight", &highlight, + "ctags|c", &ctags, + "help|h", &help, + "etags|e", &etags, + "etagsAll", &etagsAll, + "tokenCount|t", &tokenCount, + "syntaxCheck|s", &syntaxCheck, + "ast|xml", &ast, + "imports|i", &imports, + "recursiveImports", &recursiveImports, + "outline|o", &outline, + "tokenDump", &tokenDump, + "styleCheck|S", &styleCheck, + "defaultConfig", &defaultConfig, + "declaration|d", &symbolName, + "config", &configLocation, + "report", &report, + "reportFormat", &reportFormat, + "reportFile", &reportFile, + "I", &importPaths, + "version", &printVersion, + "muffinButton", &muffin, + "explore", &explore, + "skipTests", &skipTests, + "errorFormat|f", &errorFormat); + } (); //dfmt on } catch (ConvException e) From 488cec531d3355003ab1f7199d422b5a1278d619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:25:55 +0200 Subject: [PATCH 13/16] Use more tabs --- src/dscanner/main.d | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/dscanner/main.d b/src/dscanner/main.d index 6905864b..8a2c9836 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -76,7 +76,7 @@ else try { // dfmt off - () @trusted { + () @trusted { getopt(args, std.getopt.config.caseSensitive, "sloc|l", &sloc, "highlight", &highlight, @@ -109,22 +109,22 @@ else } catch (ConvException e) { - () @trusted { - stderr.writeln(e.msg); - } (); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } catch (GetOptException e) { - () @trusted { - stderr.writeln(e.msg); - } (); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } if (muffin) { - () @trusted { + () @trusted { stdout.writeln(` ___________ __(#*O 0** @%*)__ _(%*o#*O%*0 #O#%##@)_ @@ -134,16 +134,16 @@ else |I|I|I|I|I|I|I|I|I|I| |I|I|I|I|I|I|I|I|I|I| |I|I|I|I|I|I|I|I|I|I|`); - } (); + } (); return 0; } if (explore) { - () @trusted { - stdout.writeln("D-Scanner: Scanning..."); + () @trusted { + stdout.writeln("D-Scanner: Scanning..."); stderr.writeln("D-Scanner: No new astronomical objects discovered."); - } (); + } (); return 1; } From d9a05f20ba9aebae461255896ea68034279aa833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:26:57 +0200 Subject: [PATCH 14/16] Use tabs --- src/dscanner/main.d | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dscanner/main.d b/src/dscanner/main.d index 8a2c9836..a3a4474e 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -109,17 +109,17 @@ else } catch (ConvException e) { - () @trusted { - stderr.writeln(e.msg); - } (); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } catch (GetOptException e) { - () @trusted { - stderr.writeln(e.msg); - } (); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } if (muffin) From 0a2ad2950e102bdd73e2363fc7c930734555bc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:27:41 +0200 Subject: [PATCH 15/16] More tabs --- src/dscanner/main.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dscanner/main.d b/src/dscanner/main.d index a3a4474e..51ae780a 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -116,10 +116,10 @@ else } catch (GetOptException e) { - () @trusted { - stderr.writeln(e.msg); - } (); - return 1; + () @trusted { + stderr.writeln(e.msg); + } (); + return 1; } if (muffin) From 1ae1e058f5f85d7af49f765328674d8069371c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Sun, 22 Aug 2021 23:29:09 +0200 Subject: [PATCH 16/16] Correct indentation of main --- src/dscanner/main.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dscanner/main.d b/src/dscanner/main.d index 51ae780a..c089e1e4 100644 --- a/src/dscanner/main.d +++ b/src/dscanner/main.d @@ -40,11 +40,11 @@ import dsymbol.modulecache; @safe: version (unittest) - void main() @trusted +void main() @trusted { } else - int main(string[] args) @trusted +int main(string[] args) @trusted { bool sloc; bool highlight;