anz-bank / sysl

Sysl (pronounced "sizzle") is a system specification language
https://sysl.io
Apache License 2.0
122 stars 42 forks source link

fix #882, add better validator #910

Closed nofun97 closed 4 years ago

nofun97 commented 4 years ago

Fixes #882 .

Changes proposed in this pull request:

sysl validate command now has linter warnings, it checks the following:

  1. Return statements that does not use ok
  2. Check that endpoint exists in a call statement
  3. Check for case-sensitive app definition

Checklist:

codecov[bot] commented 4 years ago

Codecov Report

Merging #910 into master will increase coverage by 1.10%. The diff coverage is 87.08%.

@@            Coverage Diff             @@
##           master     #910      +/-   ##
==========================================
+ Coverage   83.35%   84.45%   +1.10%     
==========================================
  Files          73       75       +2     
  Lines       10609    10482     -127     
==========================================
+ Hits         8843     8853      +10     
+ Misses       1432     1318     -114     
+ Partials      334      311      -23     
Impacted Files Coverage Δ
pkg/pbutil/output.go 76.00% <ø> (-0.48%) :arrow_down:
pkg/syslwrapper/test_helper.go 57.89% <ø> (-1.42%) :arrow_down:
pkg/importer/importer.go 63.15% <63.15%> (ø)
pkg/mod/gomod.go 73.68% <66.66%> (+1.27%) :arrow_up:
pkg/mod/module.go 66.66% <72.72%> (+0.95%) :arrow_up:
pkg/parse/parse.go 85.34% <73.07%> (+1.37%) :arrow_up:
pkg/importer/openapi.go 83.59% <82.67%> (-5.86%) :arrow_down:
pkg/parse/listener_impl.go 89.62% <86.48%> (+0.11%) :arrow_up:
pkg/importer/swagger.go 81.48% <88.88%> (+1.88%) :arrow_up:
pkg/parse/linter.go 90.84% <90.84%> (ø)
... and 20 more
nofun97 commented 4 years ago

@anz-gordonj7

1. Move the linter functions to (at least) their own file, listener_impl.go is way too big already.

👍 will move it to its own file

2. why make these linter warnings instead of validation errors?

The plan is later to make sysl validate fails too but it seems that's going to be a big change. The sysl modules are loaded before executing the command so it's going to be tricky. So I thought this PR should be just about detecting the problems and have another PR that will make sysl validate fail.