Skip to content
7 changes: 4 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/dscanner/analysis/allman.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/asm_style.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/assert_without_msg.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import dparse.ast;
import std.stdio;
import std.algorithm;



/**
* Check that all asserts have an explanatory message.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/auto_function.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import dparse.lexer;
import std.stdio;
import std.algorithm.searching : any;



/**
* Checks for auto functions without return statement.
*
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/auto_ref_assignment.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import dparse.lexer;
import dparse.ast;
import dscanner.analysis.base;



/**
* Checks for assignment to auto-ref function parameters.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/dscanner/analysis/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,7 +83,7 @@ protected:
override void visit(const T structDec)
{
inAggregate = true;
structDec.accept(this);
() @trusted { structDec.accept(this); } ();
inAggregate = false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/builtin_property_names.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import dscanner.analysis.helpers;
import dsymbol.scope_;
import std.algorithm : map;



/**
* The following code should be killed with fire:
* ---
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/comma_expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.lexer;
import dscanner.analysis.base;
import dsymbol.scope_;



/**
* Check for uses of the comma expression.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module dscanner.analysis.config;

import inifiled;



/// Returns: A default configuration.
StaticAnalysisConfig defaultStaticAnalysisConfig()
{
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/constructors.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import dscanner.analysis.base;
import dscanner.analysis.helpers;
import dsymbol.scope_ : Scope;



final class ConstructorCheck : BaseAnalyzer
{
alias visit = BaseAnalyzer.visit;
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/del.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import dparse.lexer;
import dscanner.analysis.base;
import dsymbol.scope_;



/**
* Checks for use of the deprecated 'delete' keyword
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/duplicate_attribute.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/dscanner/analysis/enumarrayliteral.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down Expand Up @@ -52,6 +54,6 @@ final class EnumArrayLiteralCheck : BaseAnalyzer
~ part.identifier.text ~ " = [ ...' instead.");
}
}
autoDec.accept(this);
() @trusted { autoDec.accept(this); } ();
}
}
2 changes: 2 additions & 0 deletions src/dscanner/analysis/final_attribute.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dscanner.analysis.helpers;
import dparse.ast;
import dparse.lexer;



/**
* Checks for useless usage of the final attribute.
*
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/fish.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/dscanner/analysis/has_public_example.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -332,4 +334,3 @@ unittest

stderr.writeln("Unittest for HasPublicExampleCheck passed.");
}

2 changes: 2 additions & 0 deletions src/dscanner/analysis/helpers.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/if_constraints_indent.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/if_statements.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.formatter;
import dscanner.analysis.base;
import dsymbol.scope_ : Scope;



final class IfStatementCheck : BaseAnalyzer
{
alias visit = BaseAnalyzer.visit;
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/ifelsesame.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/imports_sortedness.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.ast;

import std.stdio;



/**
* Checks the sortedness of module imports
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/incorrect_infinite_range.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dscanner.analysis.helpers;
import dparse.ast;
import dparse.lexer;



/**
* Checks for incorrect infinite range definitions
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/label_var_same_name_check.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/lambda_return_check.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.lexer;
import dscanner.analysis.base;
import dscanner.utils : safeAccess;



final class LambdaReturnCheck : BaseAnalyzer
{
alias visit = BaseAnalyzer.visit;
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/length_subtraction.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/line_length.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import dparse.lexer;

import std.typecons : tuple, Tuple;



/**
* Checks for lines longer than 120 characters
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/local_imports.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/logic_precedence.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import dscanner.analysis.base;
import dscanner.analysis.helpers;
import dsymbol.scope_;



/**
* Checks for code with confusing && and || operator precedence
* ---
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/mismatched_args.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/numbers.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/opequals_without_tohash.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/range.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/dscanner/analysis/redundant_attributes.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -277,7 +279,7 @@ unittest
assertAnalyzerWarnings(q{
unittest
{
@safe:

@safe void foo();
@system
{
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/redundant_parens.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.lexer;
import dscanner.analysis.base;
import dsymbol.scope_ : Scope;



/**
* Checks for redundant parenthesis
*/
Expand Down
3 changes: 2 additions & 1 deletion src/dscanner/analysis/run.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -605,4 +607,3 @@ MessageSet analyze(string fileName, const Module m, const StaticAnalysisConfig a

return set;
}

4 changes: 3 additions & 1 deletion src/dscanner/analysis/static_if_else.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dparse.lexer;
import dscanner.analysis.base;
import dscanner.utils : safeAccess;



/**
* Checks for potentially mistaken static if / else if.
*
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/stats_collector.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import dparse.ast;
import dparse.lexer;
import dscanner.analysis.base;



final class StatsCollector : BaseAnalyzer
{
alias visit = ASTVisitor.visit;
Expand Down
Loading