-
-
Notifications
You must be signed in to change notification settings - Fork 840
feat: add empty module validation #4794
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
Open
vitorsouzaalmeida
wants to merge
11
commits into
gleam-lang:main
Choose a base branch
from
vitorsouzaalmeida:feat/empty-module-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3a2285b
feat: add empty module validation
vitorsouzaalmeida f736d45
refactor: move empty_modules to a functional approach
vitorsouzaalmeida 3609fa3
refactor: use variable directly in the format
vitorsouzaalmeida a740b44
minor: fmt
vitorsouzaalmeida 221c60a
fix: add missing warning on wasm compiler
vitorsouzaalmeida 45590fc
doc: add changes to CHANGELOG.md
vitorsouzaalmeida e17568c
doc: move my changes to CHANGELOG bottom
vitorsouzaalmeida 0850425
doc: add code explanation
vitorsouzaalmeida 545eaa5
refactor: check for module interface rather than AST
vitorsouzaalmeida f46b686
refactor: improve empty module validation and warnings
vitorsouzaalmeida daca0cc
fix: wasm
vitorsouzaalmeida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name = "empty_module_warning" | ||
version = "1.0.0" | ||
description = "Test package with empty modules" | ||
licences = ["Apache-2.0"] | ||
|
||
[dependencies] | ||
gleam_stdlib = ">= 0.44.0 and < 2.0.0" |
1 change: 1 addition & 0 deletions
1
test-package-compiler/cases/empty_module_warning/src/empty.gleam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// This is an empty module |
3 changes: 3 additions & 0 deletions
3
test-package-compiler/cases/empty_module_warning/src/main.gleam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn main() { | ||
"This module has public definitions" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...-compiler/src/snapshots/test_package_compiler__generated_tests__empty_module_warning.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
source: test-package-compiler/src/generated_tests.rs | ||
expression: "./cases/empty_module_warning" | ||
snapshot_kind: text | ||
--- | ||
//// /out/lib/the_package/_gleam_artefacts/empty.cache | ||
<.cache binary> | ||
|
||
//// /out/lib/the_package/_gleam_artefacts/empty.cache_meta | ||
<53 byte binary> | ||
|
||
//// /out/lib/the_package/_gleam_artefacts/empty.erl | ||
-module(empty). | ||
|
||
|
||
//// /out/lib/the_package/_gleam_artefacts/main.cache | ||
<.cache binary> | ||
|
||
//// /out/lib/the_package/_gleam_artefacts/main.cache_meta | ||
<61 byte binary> | ||
|
||
//// /out/lib/the_package/_gleam_artefacts/main.erl | ||
-module(main). | ||
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). | ||
-define(FILEPATH, "src/main.gleam"). | ||
-export([main/0]). | ||
|
||
-file("src/main.gleam", 1). | ||
-spec main() -> binary(). | ||
main() -> | ||
<<"This module has public definitions"/utf8>>. | ||
|
||
|
||
//// /out/lib/the_package/ebin/empty_module_warning.app | ||
{application, empty_module_warning, [ | ||
{vsn, "1.0.0"}, | ||
{applications, [gleam_stdlib]}, | ||
{description, "Test package with empty modules"}, | ||
{modules, [empty, | ||
main]}, | ||
{registered, []} | ||
]}. | ||
|
||
|
||
//// Warning | ||
warning: Empty module | ||
|
||
Module 'empty' contains no public definitions. | ||
Hint: Consider adding public functions, types, or constants, or removing this module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
source: test-package-compiler/src/generated_tests.rs | ||
expression: "./cases/not_overwriting_erlang_module" | ||
snapshot_kind: text | ||
--- | ||
//// /out/lib/the_package/_gleam_artefacts/[email protected] | ||
<.cache binary> | ||
|
@@ -20,3 +21,10 @@ expression: "./cases/not_overwriting_erlang_module" | |
{modules, [app@code]}, | ||
{registered, []} | ||
]}. | ||
|
||
|
||
//// Warning | ||
warning: Empty module | ||
|
||
Module 'app/code' contains no public definitions. | ||
Hint: Consider adding public functions, types, or constants, or removing this module. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.