Skip to content

Commit

Permalink
Add lint_filesystem to be listed in all available lints web page.
Browse files Browse the repository at this point in the history
It is not a untyped/typed analysis, but let's list it with everything.

Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Jul 25, 2024
1 parent 38a6b30 commit 6bacc7b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Lint_filesystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@ let check db =
| Library l -> on_library l)
db
;;

let docs =
{|
### What it does
Checks that dune project tree is well formed

### Why is is important?

All modules should have .mli interfaces.
The .mli files allow to

* hide some structure items
* write documentation for modules.
* hide dependencies between modules (i.e. speedup compilation)

Without .mli files all your functions will be 'public' in the sence of C++ style OOP.
Usually people autogenerate .mli files and all defined values in that time become public.
Zanuda is able to detect this via `zanuda -unused-decls .`.
But in some cases, .mli files may be too heavy, for example, when we write many type
declarations (sort of AST) with deriving attributes.
In that case .mli file is almost identical to .ml.
To workaround this, this check allows file with a suffix 'ast.ml' not to have an .mli interface file.

TODO: Add custom configuration for this.

|}
|> Stdlib.String.trim
;;

let describe_as_json () = Utils.describe_as_clippy_json "lint_filesystem" ~docs
2 changes: 2 additions & 0 deletions src/Lint_filesystem.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val check : Dune_project.t list -> unit
val describe_as_json : unit -> Yojson.Safe.t
1 change: 1 addition & 0 deletions src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ let () =
L.describe_as_json ())
; List.map typed_linters ~f:(fun (module L : LINT.TYPED) ->
L.describe_as_json ())
; [ Lint_filesystem.describe_as_json () ]
]
in
let ch = Caml.open_out filename in
Expand Down

0 comments on commit 6bacc7b

Please sign in to comment.