Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
56d9933
Update README
RazvanN7 Jan 10, 2022
0b121c7
Add dmd-as-a-library submodule (#2)
RazvanN7 Jan 12, 2022
d6e6808
Add GH Actions build script (#4)
edi33416 Jan 26, 2022
1960b5f
Removed libdparse from imports print functionality (#3)
lucica28 Jan 28, 2022
379b3f7
Fix failing tester + add unittest for imports (#7)
RazvanN7 Feb 2, 2022
48158f4
Add style checker (#9)
edi33416 Feb 3, 2022
f79fcf5
Update action to build dlang fork
edi33416 Feb 10, 2022
fc8aef9
Fix linter errors
edi33416 Feb 10, 2022
a8ae1b3
Add dmd dependencies to dub.json
edi33416 Feb 10, 2022
d2a5d7a
Add dmd dependencies to build.bat
edi33416 Feb 10, 2022
f6961ac
Replace libdparse in enum array functionality
lucica28 Apr 13, 2022
7c9f8cb
replace libdparse in objectconst functionality + unittests integratio…
lucica28 Jul 9, 2022
0c470ea
replace libdparse in delete check (#21)
lucica28 Jul 20, 2022
1d8e8f3
Update dmd (#23)
lucica28 Aug 10, 2022
0b97575
Update dmd (#25)
lucica28 Oct 6, 2022
1e25cf3
Fix version flags for gdc and ldc2 (#32)
edi33416 Oct 27, 2022
3b9fe15
replace libparse in final attribute visitor (#34)
lucica28 Oct 30, 2022
1c9879f
update dmd (#37)
lucica28 Nov 1, 2022
fa2a67d
replace libparse in incorrect infinite range visitor (#33)
lucica28 Nov 1, 2022
3905769
update dmd (#39)
lucica28 Nov 4, 2022
8a7fe0b
replace libdparse in imports sortedness visitor (#35)
lucica28 Nov 4, 2022
8bbaf8e
replace libdparse in redundant attributes visitor (#40)
lucica28 Nov 10, 2022
ec0d82e
replace libdparse in length subtraction visitor (#42)
lucica28 Nov 11, 2022
56f7d99
replace libdparse in explicitly annotated unittests check (#44)
lucica28 Nov 14, 2022
bba7536
replace libdparse in alias style visitor (#38)
lucica28 Nov 14, 2022
fd0d4e2
update dmd (#48)
lucica28 Nov 18, 2022
35deff3
replace libdparse in constructor check (#43)
lucica28 Nov 25, 2022
697e59d
replace libdparse in local imports visitor (#45)
lucica28 Dec 1, 2022
117c48a
replace libdpase in assert without msg visitor (#50)
lucica28 Dec 1, 2022
1591f9a
replace libparse in opequals without tohash visitor (#53)
lucica28 Dec 2, 2022
b905115
replace libdparse in auto ref assignment (#51)
lucica28 Dec 2, 2022
9f961bf
replace libdparse in logic precedence visitor (#54)
lucica28 Dec 2, 2022
88ea8f9
replace libdparse in builtin properties visitor (#52)
lucica28 Dec 2, 2022
dcb9e0b
update dmd (#57)
lucica28 Dec 13, 2022
c115d9f
replace libdparse in backwards range check (#58)
lucica28 Dec 16, 2022
cd2b2e0
update dmd and include the API needed for semantic analysis (#66)
lucica28 May 19, 2023
a6c7de9
replace libdparse in redundant parens check (#61)
lucica28 May 22, 2023
3c3eb1f
replace libdparse in statif if else visitor (#56)
lucica28 May 22, 2023
faf939a
replace libdparse in useless assert (#63)
lucica28 May 24, 2023
47dc93d
replace libdparse in exception check (#68)
lucica28 May 25, 2023
a7545fc
replace libdparse in unused label check (#65)
lucica28 May 26, 2023
b45b268
delete float operator check (#71)
lucica28 May 29, 2023
e73a8a8
replace libdparse in trust_too_much visitor (#70)
lucica28 May 29, 2023
52b2a16
Add null terminator to string pointers (#77)
Vladiwostok Nov 1, 2023
608e773
Replace libdparse in AsmStyleCheck (#75)
Vladiwostok Nov 7, 2023
3698c89
Use DMD in RedundantStorageClassCheck (#84)
Vladiwostok Jan 15, 2024
d76aa08
Fix branch after rebase
edi33416 Jan 29, 2024
aefc3cb
Fix branch after rebase
edi33416 Feb 5, 2024
e81443d
Update dmd submodule reference
edi33416 Feb 5, 2024
594a912
Disable parens errors. Needs fixing
edi33416 Feb 5, 2024
470df48
Disable integration tests due to autofix. Needs fixing
edi33416 Feb 5, 2024
fe86188
Update dub.json to latest dmd commit
edi33416 Feb 5, 2024
a8fd148
Fix style errors
edi33416 Feb 12, 2024
0eb408f
Update build bat
edi33416 Feb 12, 2024
721b2cf
Fix GDC build
edi33416 Feb 14, 2024
7d8d89c
Delete DuplicateAttributeCheck (#79)
Vladiwostok Feb 22, 2024
f1e3b77
Update dmd to latest version (02d6d07a69280f8cc88380a682717bb67ca485f…
Vladiwostok Mar 5, 2024
cd8f403
Use DMD in NumberStyleCheck (#88)
Vladiwostok Mar 5, 2024
4e69052
Replace libdparse in IfElseSameCheck (#81)
Vladiwostok Mar 18, 2024
de6c0a3
Use DMD in CyclomaticComplexityCheck (#85)
Vladiwostok Mar 19, 2024
0e34c83
Replace libdparse with DMD in LabelVarNameCheck (#101)
Vladiwostok Apr 8, 2024
eb09004
Delete IfStatementCheck (#106)
Vladiwostok Apr 10, 2024
4a0016c
Delete CommaExpressionCheck (#104)
Vladiwostok Apr 10, 2024
f4dd1c0
Replace libdparse with DMD in LambdaReturnCheck (#114)
Vladiwostok Apr 15, 2024
9fd84a0
Replace libdparse with DMD in AlwaysCurlyCheck (#109)
Vladiwostok Apr 15, 2024
a9f1348
Replace libdparse with DMD in StyleChecker (#111)
Vladiwostok Apr 15, 2024
af525da
Replace libdparse with DMD in AutoFunctionChecker (#103)
Vladiwostok Apr 15, 2024
2f7e135
Fix github actions for macos (#135)
Vladiwostok May 7, 2024
026eb8b
Update dmd to latest version (b02f7183804f583776db69c1d8b355671e30621…
Vladiwostok Aug 6, 2024
9c38597
Replace libdparse with DMD in UnusedParameterCheck (#116)
Vladiwostok Aug 6, 2024
16af24d
Replace libdparse with DMD in UnusedVariableCheck (#119)
Vladiwostok Aug 6, 2024
a232713
Replace libdparse with DMD in UnmodifiedFinder (#117)
Vladiwostok Aug 6, 2024
ab17df9
Replace libdparse with DMD in BodyOnDisabledFuncsCheck (#127)
Vladiwostok Aug 8, 2024
c0cb2cf
Replace libdparse with DMD in UselessInitializerChecker (#121)
Vladiwostok Aug 12, 2024
8d7196a
Replace libdparse with DMD in HasPublicExampleCheck (#130)
Vladiwostok Aug 12, 2024
aece8d2
Replace libdparse with DMD in LineLengthCheck (#134)
Vladiwostok Aug 15, 2024
99dcc4b
Replace libdparse in UnusedResultChecker (#80)
Vladiwostok Aug 19, 2024
d27342b
Separate analyze with dmd and autofix flows from libdparse analyze fl…
Vladiwostok Sep 25, 2024
fdb8ad5
Implement autofix flow for dmd as a library and fix autofix for EnumA…
Vladiwostok Sep 27, 2024
f8cc9cd
Update dmd (6f1b331a6a29e3dddc647ec04dfc9cd85064f3e9) (#141)
Vladiwostok Sep 27, 2024
355ce40
Respect "skip unittest" user configuration (#139)
Vladiwostok Sep 29, 2024
e52e297
Update dmd to ef02f08456762548555b1476a6e32c6e6af6320c (#146)
Vladiwostok Oct 3, 2024
cec745a
Fix Autofix for DeleteCheck (#144)
Vladiwostok Oct 3, 2024
ea4c90d
Replace libdparse with DMD in VcallCtorChecker (#145)
Vladiwostok Oct 5, 2024
3b1a43a
Fix Autofix for AlwaysCurlyCheck (#148)
Vladiwostok Oct 5, 2024
fc72595
Fix Autofix for ExplicitlyAnnotatedUnittestCheck (#150)
Vladiwostok Oct 7, 2024
3ba7a37
Fix Autofix for AutoFunctionChecker (#149)
Vladiwostok Oct 7, 2024
cc40e68
Fix unittests (#153)
RazvanN7 Oct 8, 2024
bb68206
Fail unittests on DMD parsing errors (#154)
Vladiwostok Oct 8, 2024
6c3d96e
Replace libdparse with DMD in AllManCheck (#125)
Vladiwostok Oct 9, 2024
fc8a68b
Respect @nolint user attribute (#158)
Vladiwostok Oct 15, 2024
d9f5b05
Replace libdparse with DMD in MismatchedArgumentCheck (#161)
Vladiwostok Oct 23, 2024
3f28b37
Use rawWrite for writing test files in unit tests (#168)
Vladiwostok Nov 6, 2024
0c11c65
Update dmd to 4a90885ef8e0fc29334da91a4318f9ab52af9f80 (#164)
Vladiwostok Nov 6, 2024
29717d0
Remove unused nolint code (#162)
Vladiwostok Nov 6, 2024
116a4ea
Remove unused imports (#166)
Vladiwostok Nov 6, 2024
8043548
Replace libdparse with DMD in IfConstraintsIndentCheck (#128)
Vladiwostok Nov 8, 2024
14ccbeb
Replace libdparse with DMD in UndocumentedDeclarationCheck (#123)
Vladiwostok Nov 8, 2024
7980ac3
Fix Autofix for LambdaReturnCheck (#151)
Vladiwostok Nov 9, 2024
f6c367c
Replace libdparse with DMD in FunctionAttributeCheck (#156)
Vladiwostok Nov 10, 2024
8c61dc3
Fix Autofix for LengthSubtractionCheck (#169)
Vladiwostok Nov 10, 2024
ba22ec2
Fix Autofix for FinalAttributeChecker (#170)
Vladiwostok Nov 10, 2024
ed35bfc
Fix nolint in StyleChecker (#171)
Vladiwostok Nov 10, 2024
9c7f594
Fix Autofix in StaticIfElse (#157)
Vladiwostok Nov 10, 2024
795d825
Cleanup code and fix integration tests (#172)
Vladiwostok Dec 10, 2024
d2ef7fc
Fix CI
Vladiwostok Jan 12, 2025
0327db1
Update DMD to 10eb368c1b8c323e1921e991cb2bd8fce535e9b2
Vladiwostok Jan 12, 2025
926216b
Remove dead code
Vladiwostok Jan 12, 2025
3c5c3ce
Update DMD to a4cbc08f5bc1a2f7ce3289103198c473671e94c0
Vladiwostok Mar 17, 2025
a944642
Disable test for DeleteCheck failing due to new compilation warning
Vladiwostok Mar 17, 2025
5b2dc84
[TEMP] Enable debug ssh
Vladiwostok Mar 17, 2025
b593c36
Return AAs by `ref` to avoid lvalue compile errors
Albert24GG Aug 31, 2025
c7df69a
Remove `dmd` version from `dub.selections`
Albert24GG Sep 2, 2025
96b1f61
Bump dmd version
Albert24GG Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dfmt_template_constraint_style = conditional_newline_indent

[*.yml]
indent_style = space
indent_size = 2
indent_size = 2
25 changes: 22 additions & 3 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ jobs:
submodules: 'recursive'
fetch-depth: 0

# Uncomment to get a ssh connection inside the GH Actions runner
- name: Setup upterm session
uses: lhotari/action-upterm@v1

# Install the host compiler (DMD or LDC)
# Also grabs DMD for GDC to include dub + rdmd
- name: Install ${{ matrix.compiler.version }}
Expand All @@ -102,6 +106,10 @@ jobs:
sudo apt-get install gdc-12 -y
gdc-12 --version

- name: Setup upterm session
if: ${{ matrix.build.type == 'dub' && matrix.host == 'ubuntu-22.04'}}
uses: lhotari/action-upterm@v1

# Compile D-Scanner and execute all tests without dub
- name: Build and test without dub
if: ${{ matrix.build.type == 'make' }}
Expand All @@ -114,7 +122,8 @@ jobs:
./build.bat
./build.bat test
else
make "-j$(nproc)" all test
NUM_PROC=$(nproc || getconf _NPROCESSORS_ONLN || 1)
make "-j$((NUM_PROC / 2))" all test
fi

# Compile D-Scanner and execute all tests using a specific dependency version
Expand Down Expand Up @@ -159,10 +168,20 @@ jobs:
"./bin/dscanner$EXE" --styleCheck -f "$FORMAT" src

- name: Integration Tests
run: ./it.sh
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
./it.sh Windows
else
./it.sh Unix
fi
working-directory: tests
shell: bash

- name: Run style checks
if: ${{ matrix.compiler.dmd == 'dmd' && matrix.build.type == 'make' }}
run: |
make style

# Parse phobos to check for failures / crashes / ...
- name: Checkout Phobos
uses: actions/checkout@v4
Expand All @@ -171,7 +190,7 @@ jobs:
path: phobos

- name: Apply D-Scanner to Phobos
if: ${{ matrix.build.version != 'min libdparse'}} # Older versions crash with "Invalid UTF..."
if: ${{ matrix.build.version != 'min libdparse'}} # Older versions crash with "Invalid UTF..."
working-directory: phobos
shell: bash
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Sublime Text 2
*.sublime-workspace

# Idea stuff
.idea/

# Subversion
.svn/

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
[submodule "DCD"]
path = DCD
url = https://github.com/dlang-community/DCD.git
[submodule "dmd"]
path = dmd
url = [email protected]:dlang/dmd.git
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
D-Scanner is a tool for analyzing D source code

### Building and installing
First make sure that you have all the source code. Run ```git submodule update --init --recursive```

First, make sure that you have fetched the upstream: [email protected]:dlang-community/D-Scanner.git

```
git remote add upstream [email protected]:dlang-community/D-Scanner.git
git fetch upstream
```

Secondly, make sure that you have all the source code. Run ```git submodule update --init --recursive```
after cloning the project.

To build D-Scanner, run ```make``` (or the build.bat file on Windows).
Expand Down
96 changes: 91 additions & 5 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if %githashsize% == 0 (
move /y bin\githash_.txt bin\githash.txt
)

set DFLAGS=-O -release -Jbin %MFLAGS%
set TESTFLAGS=-g -w -Jbin
set DFLAGS=-O -release -version=StdLoggerDisableWarning -version=CallbackAPI -version=DMDLIB -version=MARS -version=NoBackend -version=NoMain -Jbin -Jdmd -Jdmd\compiler\src\dmd\res %MFLAGS%
set TESTFLAGS=-g -w -version=StdLoggerDisableWarning -version=CallbackAPI -version=DMDLIB -version=MARS -version=NoBackend -version=NoMain -Jbin -Jdmd -Jdmd\compiler\src\dmd\res
set CORE=
set LIBDPARSE=
set STD=
Expand All @@ -29,6 +29,44 @@ set DSYMBOL=
set CONTAINERS=
set LIBDDOC=

set DMD_FRONTEND_DENYLIST=^
dmd\compiler\src\dmd\mars.d^
dmd\compiler\src\dmd\dmsc.d^
dmd\compiler\src\dmd\e2ir.d^
dmd\compiler\src\dmd\eh.d^
dmd\compiler\src\dmd\glue.d^
dmd\compiler\src\dmd\iasmdmd.d^
dmd\compiler\src\dmd\irstate.d^
dmd\compiler\src\dmd\lib.d^
dmd\compiler\src\dmd\libelf.d^
dmd\compiler\src\dmd\libmach.d^
dmd\compiler\src\dmd\libmscoff.d^
dmd\compiler\src\dmd\libomf.d^
dmd\compiler\src\dmd\objc_glue.d^
dmd\compiler\src\dmd\s2ir.d^
dmd\compiler\src\dmd\scanelf.d^
dmd\compiler\src\dmd\scanmach.d^
dmd\compiler\src\dmd\scanmscoff.d^
dmd\compiler\src\dmd\scanomf.d^
dmd\compiler\src\dmd\tocsym.d^
dmd\compiler\src\dmd\toctype.d^
dmd\compiler\src\dmd\tocvdebug.d^
dmd\compiler\src\dmd\toobj.d^
dmd\compiler\src\dmd\todt.d^
dmd\compiler\src\dmd\toir.d

set DMD_FRONTEND_SRC=
for %%x in (dmd\compiler\src\dmd\common\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\root\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\visitor\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\mangle\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\*.d) do (
echo "%DMD_FRONTEND_DENYLIST%" | findstr /i /c:"%%x" >nul
if errorlevel 1 (
set "DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x"
)
)

for %%x in (src\dscanner\*.d) do set CORE=!CORE! %%x
for %%x in (src\dscanner\analysis\*.d) do set ANALYSIS=!ANALYSIS! %%x
for %%x in (libdparse\src\dparse\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
Expand All @@ -45,14 +83,62 @@ for %%x in (containers\src\containers\internal\*.d) do set CONTAINERS=!CONTAINER
if "%1" == "test" goto test_cmd

@echo on
%DC% %MFLAGS% %CORE% %STD% %LIBDPARSE% %LIBDDOC% %ANALYSIS% %INIFILED% %DSYMBOL% %CONTAINERS% %DFLAGS% -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -I"libddoc\common\source" -ofbin\dscanner.exe
%DC% %MFLAGS%^
%CORE%^
%STD%^
%LIBDPARSE%^
%LIBDDOC%^
%ANALYSIS%^
%INIFILED%^
%DSYMBOL%^
%CONTAINERS%^
%DMD_FRONTEND_SRC%^
%DFLAGS%^
-Ilibdparse\src^
-IDCD\dsymbol\src^
-Icontainers\src^
-Ilibddoc\src^
-Ilibddoc\common\source^
-Idmd\compiler\src^
-ofbin\dscanner.exe
goto eof

:test_cmd
@echo on
set TESTNAME="bin\dscanner-unittest"
%DC% %MFLAGS% %STD% %LIBDPARSE% %LIBDDOC% %INIFILED% %DSYMBOL% %CONTAINERS% -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -lib %TESTFLAGS% -of%TESTNAME%.lib
if exist %TESTNAME%.lib %DC% %MFLAGS% %CORE% %ANALYSIS% %TESTNAME%.lib -I"src" -I"inifiled\source" -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -I"libddoc\common\source" -unittest %TESTFLAGS% -of%TESTNAME%.exe
%DC% %MFLAGS% ^
%STD%^
%LIBDPARSE%^
%LIBDDOC%^
%INIFILED%^
%DSYMBOL%^
%CONTAINERS%^
%DMD_FRONTEND_SRC%^
-I"libdparse\src"^
-I"DCD\dsymbol\src"^
-I"containers\src"^
-I"libddoc\src"^
-I"dmd\compiler\src"^
-I"dmd\compiler\src\dmd\res"^
%TESTFLAGS%^
-lib^
-of%TESTNAME%.lib
if exist %TESTNAME%.lib %DC% %MFLAGS%^
%CORE%^
%ANALYSIS%^
%TESTNAME%.lib^
-I"src"^
-I"inifiled\source"^
-I"libdparse\src"^
-I"DCD\dsymbol\src"^
-I"containers\src"^
-I"libddoc\src"^
-I"libddoc\common\source"^
-I"dmd\compiler\src"^
-I"dmd\compiler\src\dmd\res"^
-unittest^
%TESTFLAGS%^
-of%TESTNAME%.exe
if exist %TESTNAME%.exe %TESTNAME%.exe

if exist %TESTNAME%.obj del %TESTNAME%.obj
Expand Down
1 change: 1 addition & 0 deletions changelog/dscanner.assert-without-message.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid checking `enforce` calls as it is phobos specific.
3 changes: 3 additions & 0 deletions changelog/dscanner.comma-expression.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove the check for comma expression check
e.g. (int a = 3, a + 7)
This check is no longer necessary since comma expression have been removed from the D language.
2 changes: 2 additions & 0 deletions changelog/dscanner.duplicate-attribute-check.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove the check for duplicate attributes (@property, @safe, @trusted, @system, pure, nothrow).
This check is no longer necessary since having duplicated attributes is now a compiler error.
1 change: 1 addition & 0 deletions changelog/dscanner.if-statements.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove IfStatementCheck, as it has been disabled in 2015 due to false positives and untouched ever since then.
19 changes: 19 additions & 0 deletions changelog/dscanner.struct-ctor-check.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Remove the check regarding structs with no arguments constructors.

The check is implemented in constructors.d and it warns against the usage
of both constructors with all parameters with default values and constructors
without any arguments, as this might be confusing. This scenario, for structs,
is no longer D valid code and that's why it is being deprecated.

Let's consider the following code:

---
struct Dog
{
this() {}
this(string name = "doggie") {} // [warn]: This struct constructor can never be called with its default argument.
}
---

D-Scanner would throw and error for this particular struct, but this code
does not compile anymore hence this check is not needed anymore/
1 change: 1 addition & 0 deletions dmd
Submodule dmd added at 2d5cd3
6 changes: 5 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"dcd:dsymbol": ">=0.16.0-beta.2 <0.17.0",
"inifiled": "~>1.3.1",
"emsi_containers": "~>0.9.0",
"libddoc": "~>0.8.0"
"libddoc": "~>0.8.0",
"dmd": {
"repository": "git+https://github.com/dlang/dmd.git",
"version": "2d5cd3166b6cce7404c812a8f04156dc2f1108b5"
}
},
"targetPath" : "bin",
"stringImportPaths" : [
Expand Down
Loading
Loading