Skip to content

Commit

Permalink
Use @safe: at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Nordlöw authored and Per Nordlöw committed Aug 15, 2021
1 parent 30290bc commit de27ab9
Show file tree
Hide file tree
Showing 67 changed files with 139 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/dscanner/analysis/alias_syntax_check.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;

@safe:

/**
* Checks for uses of the old alias syntax.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/allman.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import dsymbol.scope_ : Scope;
import std.algorithm;
import std.range;

@safe:

/**
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;

@safe:

/**
* 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;

@safe:

/**
* 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;

@safe:

/**
* 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;

@safe:

/**
* Checks for assignment to auto-ref function parameters.
*/
Expand Down
2 changes: 2 additions & 0 deletions 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;

@safe:

struct Message
{
/// Name of the file where the warning was triggered
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;

@safe:

/**
* 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_;

@safe:

/**
* 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;

@safe:

/// 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;

@safe:

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_;

@safe:

/**
* 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;

@safe:

/**
* Checks for duplicate attributes such as @property, @safe,
* @trusted, @system, pure, and nothrow
Expand Down
2 changes: 2 additions & 0 deletions 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;

@safe:

void doNothing(string, size_t, size_t, string, bool)
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/explicitly_annotated_unittests.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dscanner.analysis.base;

import std.stdio;

@safe:

/**
* Requires unittests to be explicitly annotated with either @safe or @system
*/
Expand Down
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;

@safe:

/**
* 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;

@safe:

/**
* Checks for use of the deprecated floating point comparison operators.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/function_attributes.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import dparse.lexer;
import std.stdio;
import dsymbol.scope_;

@safe:

/**
* Prefer
* ---
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;

@safe:

/**
* 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;

@safe:

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;

@safe:

/**
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;

@safe:

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;

@safe:

/**
* 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;

@safe:

/**
* 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;

@safe:

/**
* 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;

@safe:

/**
* 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;

@safe:

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_;

@safe:

/**
* 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;

@safe:

/**
* 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_;

@safe:

/**
* 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_;

@safe:

/**
* 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;

@safe:

/// 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;

@safe:

/**
* Checks for long and hard-to-read number literals
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/objectconst.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;

@safe:

/**
* Checks that opEquals, opCmp, toHash, 'opCast', and toString are either const,
* immutable, or inout.
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;

@safe:

/**
* 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/pokemon.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;

@safe:

/**
* Checks for Pokémon exception handling, i.e. "gotta' catch 'em all".
*
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/properly_documented_public_functions.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import std.format : format;
import std.range.primitives;
import std.stdio;

@safe:

/**
* Requires each public function to contain the following ddoc sections
- PARAMS:
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;

@safe:

/**
* Checks for .. expressions where the left side is larger than the right. This
* is almost always a mistake.
Expand Down
2 changes: 2 additions & 0 deletions 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;

@safe:

/**
* Checks for redundant attributes. At the moment only visibility attributes.
*/
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;

@safe:

/**
* Checks for redundant parenthesis
*/
Expand Down
2 changes: 2 additions & 0 deletions src/dscanner/analysis/redundant_storage_class.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;

@safe:

/**
* Checks for redundant storage classes such immutable and __gshared, static and __gshared
*/
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}";

@safe:

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;
}

Loading

0 comments on commit de27ab9

Please sign in to comment.