Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenDream Linting #930

Merged
merged 8 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ jobs:
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/build/build --ci lint tgui-test

odlint:
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: "Lint with OpenDream"
runs-on: ubuntu-22.04
concurrency:
group: odlint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: robinraju/[email protected]
with:
repository: "OpenDreamProject/OpenDream"
tag: "latest"
fileName: "DMCompiler_linux-x64.tar.gz"
extract: true
- name: Run OpenDream
run: |
./DMCompiler_linux-x64/DMCompiler daedalus.dme --suppress-unimplemented --define=CIBUILDING

compile_all_maps:
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: Compile Maps
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ libprof.so
# Screenshot tests
/artifacts

# Running OpenDream locally
daedalus.json

# Codex Database
codex.db
codex.db-shm
codex.db-wal
codex.db-wal
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
"preLaunchTask": "Build All",
"dmb": "${workspaceFolder}/${command:CurrentDMB}",
"dreamDaemon": true
},{
"type": "opendream",
"request": "launch",
"name": "OpenDream",
"preLaunchTask": "OpenDream: compile ${command:CurrentDME}",
"json_path": "${workspaceFolder}/${command:CurrentJson}"
}
]
}
8 changes: 8 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
],
"group": "build",
"label": "tgui: sonar"
},
{
"type": "opendream",
"problemMatcher": [
"$openDreamCompiler"
],
"group": "build",
"label": "OpenDream: compile daedalus.dme"
}
]
}
19 changes: 12 additions & 7 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
#warn compiling in TESTING mode. testing() debug messages will be visible.
#endif

#ifdef CIBUILDING
#if defined(CIBUILDING) && !defined(OPENDREAM)
#define UNIT_TESTS
#endif

Expand All @@ -214,12 +214,17 @@
#define CBT
#endif

#if !defined(CBT) && !defined(SPACEMAN_DMM)
#warn Building with Dream Maker is no longer supported and will result in errors.
#warn In order to build, run BUILD.bat in the root directory.
#warn Consider switching to VSCode editor instead, where you can press Ctrl+Shift+B to build.
//Hi, Hijacking this to do DMEd-Specific Icon Overrides
#define SIMPLE_MAPHELPERS
#if defined(OPENDREAM)
#if !defined(CIBUILDING)
#warn You are building with OpenDream. Remember to build TGUI manually.
#warn You can do this by running tgui-build.cmd from the bin directory.
#endif
#else
#if !defined(CBT) && !defined(SPACEMAN_DMM)
#warn Building with Dream Maker is no longer supported and will result in errors.
#warn In order to build, run BUILD.cmd in the root directory.
#warn Consider switching to VSCode editor instead, where you can press Ctrl+Shift+B to build.
#endif
#endif

#ifdef ZASDBG
Expand Down
4 changes: 4 additions & 0 deletions daedalus.dme
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#define DEBUG
// END_PREFERENCES

#if !defined(SPACEMAN_DMM) && defined(OPENDREAM)
#include "tools/ci/od_lints.dme"
#endif

// BEGIN_INCLUDE
#include "_maps\_basemap.dm"
#include "code\_byond_version_compact.dm"
Expand Down
48 changes: 48 additions & 0 deletions tools/ci/od_lints.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//1000-1999
#pragma FileAlreadyIncluded error
#pragma MissingIncludedFile error
#pragma InvalidWarningCode error
#pragma MisplacedDirective error
#pragma UndefineMissingDirective error
#pragma DefinedMissingParen error
#pragma ErrorDirective error
#pragma WarningDirective warning
#pragma MiscapitalizedDirective error

//2000-2999
#pragma SoftReservedKeyword error
#pragma DuplicateVariable error
#pragma DuplicateProcDefinition error
#pragma PointlessParentCall error
#pragma PointlessBuiltinCall error
#pragma SuspiciousMatrixCall error
#pragma FallbackBuiltinArgument error
#pragma PointlessScopeOperator error
#pragma MalformedRange error
#pragma InvalidRange error
#pragma InvalidSetStatement error
#pragma InvalidOverride error
#pragma DanglingVarType error
#pragma MissingInterpolatedExpression error
#pragma AmbiguousResourcePath error


// NOTE: The next few pragmas are for OpenDream's experimental type checker
// This feature is still in development, elevating these pragmas outside of local testing is discouraged
// An RFC to finalize this feature is coming soon(TM)
// BEGIN TYPEMAKER
#pragma UnsupportedTypeCheck disabled
#pragma InvalidReturnType disabled
#pragma InvalidVarType disabled
#pragma ImplicitNullType disabled
#pragma LostTypeInfo disabled
// END TYPEMAKER

//3000-3999
#pragma EmptyBlock disabled
#pragma EmptyProc disabled
// NOTE: Only checks for unsafe accesses like "client.foobar" and doesn't consider if the client was already null-checked earlier in the proc
#pragma UnsafeClientAccess disabled
#pragma SuspiciousSwitchCase error
#pragma AssignmentInConditional error
#pragma PickWeightedSyntax disabled
Loading