Skip to content

Commit f5e44aa

Browse files
authored
Merge pull request #2078 from AlWoSp/pr/missing-global-doc
Check for missing @param and @return annotations
2 parents 8355006 + 171703c commit f5e44aa

File tree

18 files changed

+1008
-1
lines changed

18 files changed

+1008
-1
lines changed

doc/en-us/config.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Array<string>
240240
* ``"exp-in-action"``
241241
* ``"global-element"``
242242
* ``"global-in-nil-env"``
243+
* ``"incomplete-signature-doc"``
243244
* ``"index-in-func-name"``
244245
* ``"invisible"``
245246
* ``"jump-local-scope"``
@@ -284,6 +285,7 @@ Array<string>
284285
* ``"miss-sep-in-table"``
285286
* ``"miss-space-between"``
286287
* ``"miss-symbol"``
288+
* ``"missing-global-doc"``
287289
* ``"missing-parameter"``
288290
* ``"missing-return"``
289291
* ``"missing-return-value"``
@@ -449,6 +451,8 @@ object<string, string>
449451
* duplicate-doc-alias
450452
* duplicate-doc-field
451453
* duplicate-doc-param
454+
* incomplete-signature-doc
455+
* missing-global-doc
452456
* undefined-doc-class
453457
* undefined-doc-name
454458
* undefined-doc-param
@@ -572,6 +576,8 @@ object<string, string>
572576
* duplicate-doc-alias
573577
* duplicate-doc-field
574578
* duplicate-doc-param
579+
* incomplete-signature-doc
580+
* missing-global-doc
575581
* undefined-doc-class
576582
* undefined-doc-name
577583
* undefined-doc-param
@@ -792,6 +798,10 @@ object<string, string>
792798
*/
793799
"global-in-nil-env": "Any",
794800
/*
801+
Enable diagnostics for function definitions which are not fully annotated.
802+
*/
803+
"incomplete-signature-doc": "None",
804+
/*
795805
Enable diagnostics for accesses to fields which are invisible.
796806
*/
797807
"invisible": "Any",
@@ -800,6 +810,10 @@ object<string, string>
800810
*/
801811
"lowercase-global": "Any",
802812
/*
813+
Enable diagnostics for global function definitions which are not fully annotated.
814+
*/
815+
"missing-global-doc": "None",
816+
/*
803817
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
804818
*/
805819
"missing-parameter": "Any",
@@ -1044,6 +1058,10 @@ object<string, string>
10441058
*/
10451059
"global-in-nil-env": "Warning",
10461060
/*
1061+
Enable diagnostics for function definitions which are not fully annotated.
1062+
*/
1063+
"incomplete-signature-doc": "Warning",
1064+
/*
10471065
Enable diagnostics for accesses to fields which are invisible.
10481066
*/
10491067
"invisible": "Warning",
@@ -1052,6 +1070,10 @@ object<string, string>
10521070
*/
10531071
"lowercase-global": "Information",
10541072
/*
1073+
Enable diagnostics for global function definitions which are not annotated.
1074+
*/
1075+
"missing-global-doc": "Warning",
1076+
/*
10551077
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
10561078
*/
10571079
"missing-parameter": "Warning",

doc/pt-br/config.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Array<string>
240240
* ``"exp-in-action"``
241241
* ``"global-element"``
242242
* ``"global-in-nil-env"``
243+
* ``"incomplete-signature-doc"``
243244
* ``"index-in-func-name"``
244245
* ``"invisible"``
245246
* ``"jump-local-scope"``
@@ -284,6 +285,7 @@ Array<string>
284285
* ``"miss-sep-in-table"``
285286
* ``"miss-space-between"``
286287
* ``"miss-symbol"``
288+
* ``"missing-global-doc"``
287289
* ``"missing-parameter"``
288290
* ``"missing-return"``
289291
* ``"missing-return-value"``
@@ -449,6 +451,8 @@ object<string, string>
449451
* duplicate-doc-alias
450452
* duplicate-doc-field
451453
* duplicate-doc-param
454+
* incomplete-signature-doc
455+
* missing-global-doc
452456
* undefined-doc-class
453457
* undefined-doc-name
454458
* undefined-doc-param
@@ -572,6 +576,7 @@ object<string, string>
572576
* duplicate-doc-alias
573577
* duplicate-doc-field
574578
* duplicate-doc-param
579+
* incomplete-signature-doc
575580
* undefined-doc-class
576581
* undefined-doc-name
577582
* undefined-doc-param
@@ -792,6 +797,10 @@ object<string, string>
792797
*/
793798
"global-in-nil-env": "Any",
794799
/*
800+
Enable diagnostics for function definitions which are not fully annotated.
801+
*/
802+
"incomplete-signature-doc": "None",
803+
/*
795804
Enable diagnostics for accesses to fields which are invisible.
796805
*/
797806
"invisible": "Any",
@@ -800,6 +809,10 @@ object<string, string>
800809
*/
801810
"lowercase-global": "Any",
802811
/*
812+
Enable diagnostics for global function definitions which are not fully annotated.
813+
*/
814+
"missing-global-doc": "None",
815+
/*
803816
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
804817
*/
805818
"missing-parameter": "Any",
@@ -1044,6 +1057,10 @@ object<string, string>
10441057
*/
10451058
"global-in-nil-env": "Warning",
10461059
/*
1060+
Enable diagnostics for function definitions which are not fully annotated.
1061+
*/
1062+
"incomplete-signature-doc": "Warning",
1063+
/*
10471064
Enable diagnostics for accesses to fields which are invisible.
10481065
*/
10491066
"invisible": "Warning",
@@ -1052,6 +1069,10 @@ object<string, string>
10521069
*/
10531070
"lowercase-global": "Information",
10541071
/*
1072+
Enable diagnostics for global function definitions which are not annotated.
1073+
*/
1074+
"missing-global-doc": "Warning",
1075+
/*
10551076
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
10561077
*/
10571078
"missing-parameter": "Warning",

doc/zh-cn/config.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Array<string>
240240
* ``"exp-in-action"``
241241
* ``"global-element"``
242242
* ``"global-in-nil-env"``
243+
* ``"incomplete-signature-doc"``
243244
* ``"index-in-func-name"``
244245
* ``"invisible"``
245246
* ``"jump-local-scope"``
@@ -284,6 +285,7 @@ Array<string>
284285
* ``"miss-sep-in-table"``
285286
* ``"miss-space-between"``
286287
* ``"miss-symbol"``
288+
* ``"missing-global-doc"``
287289
* ``"missing-parameter"``
288290
* ``"missing-return"``
289291
* ``"missing-return-value"``
@@ -449,6 +451,8 @@ object<string, string>
449451
* duplicate-doc-alias
450452
* duplicate-doc-field
451453
* duplicate-doc-param
454+
* incomplete-signature-doc
455+
* missing-global-doc
452456
* undefined-doc-class
453457
* undefined-doc-name
454458
* undefined-doc-param
@@ -572,6 +576,8 @@ object<string, string>
572576
* duplicate-doc-alias
573577
* duplicate-doc-field
574578
* duplicate-doc-param
579+
* incomplete-signature-doc
580+
* missing-global-doc
575581
* undefined-doc-class
576582
* undefined-doc-name
577583
* undefined-doc-param
@@ -792,6 +798,10 @@ object<string, string>
792798
*/
793799
"global-in-nil-env": "Any",
794800
/*
801+
Enable diagnostics for function definitions which are not fully annotated.
802+
*/
803+
"incomplete-signature-doc": "None",
804+
/*
795805
Enable diagnostics for accesses to fields which are invisible.
796806
*/
797807
"invisible": "Any",
@@ -800,6 +810,10 @@ object<string, string>
800810
*/
801811
"lowercase-global": "Any",
802812
/*
813+
Enable diagnostics for global function definitions which are not fully annotated.
814+
*/
815+
"missing-global-doc": "None",
816+
/*
803817
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
804818
*/
805819
"missing-parameter": "Any",
@@ -1043,6 +1057,10 @@ object<string, string>
10431057
*/
10441058
"global-in-nil-env": "Warning",
10451059
/*
1060+
Enable diagnostics for function definitions which are not fully annotated.
1061+
*/
1062+
"incomplete-signature-doc": "Warning",
1063+
/*
10461064
Enable diagnostics for accesses to fields which are invisible.
10471065
*/
10481066
"invisible": "Warning",
@@ -1051,6 +1069,10 @@ object<string, string>
10511069
*/
10521070
"lowercase-global": "Information",
10531071
/*
1072+
Enable diagnostics for global function definitions which are not annotated.
1073+
*/
1074+
"missing-global-doc": "Warning",
1075+
/*
10541076
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
10551077
*/
10561078
"missing-parameter": "Warning",

doc/zh-tw/config.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Array<string>
240240
* ``"exp-in-action"``
241241
* ``"global-element"``
242242
* ``"global-in-nil-env"``
243+
* ``"incomplete-signature-doc"``
243244
* ``"index-in-func-name"``
244245
* ``"invisible"``
245246
* ``"jump-local-scope"``
@@ -284,6 +285,7 @@ Array<string>
284285
* ``"miss-sep-in-table"``
285286
* ``"miss-space-between"``
286287
* ``"miss-symbol"``
288+
* ``"missing-global-doc"``
287289
* ``"missing-parameter"``
288290
* ``"missing-return"``
289291
* ``"missing-return-value"``
@@ -449,6 +451,8 @@ object<string, string>
449451
* duplicate-doc-alias
450452
* duplicate-doc-field
451453
* duplicate-doc-param
454+
* incomplete-signature-doc
455+
* missing-global-doc
452456
* undefined-doc-class
453457
* undefined-doc-name
454458
* undefined-doc-param
@@ -572,6 +576,8 @@ object<string, string>
572576
* duplicate-doc-alias
573577
* duplicate-doc-field
574578
* duplicate-doc-param
579+
* incomplete-signature-doc
580+
* missing-global-doc
575581
* undefined-doc-class
576582
* undefined-doc-name
577583
* undefined-doc-param
@@ -792,6 +798,10 @@ object<string, string>
792798
*/
793799
"global-in-nil-env": "Any",
794800
/*
801+
Enable diagnostics for function definitions which are not fully annotated.
802+
*/
803+
"incomplete-signature-doc": "None",
804+
/*
795805
Enable diagnostics for accesses to fields which are invisible.
796806
*/
797807
"invisible": "Any",
@@ -800,6 +810,10 @@ object<string, string>
800810
*/
801811
"lowercase-global": "Any",
802812
/*
813+
Enable diagnostics for global function definitions which are not fully annotated.
814+
*/
815+
"missing-global-doc": "None",
816+
/*
803817
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
804818
*/
805819
"missing-parameter": "Any",
@@ -1043,6 +1057,10 @@ object<string, string>
10431057
*/
10441058
"global-in-nil-env": "Warning",
10451059
/*
1060+
Enable diagnostics for function definitions which are not fully annotated.
1061+
*/
1062+
"incomplete-signature-doc": "Warning",
1063+
/*
10461064
Enable diagnostics for accesses to fields which are invisible.
10471065
*/
10481066
"invisible": "Warning",
@@ -1051,6 +1069,10 @@ object<string, string>
10511069
*/
10521070
"lowercase-global": "Information",
10531071
/*
1072+
Enable diagnostics for global function definitions which are not annotated.
1073+
*/
1074+
"missing-global-doc": "Warning",
1075+
/*
10541076
Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.
10551077
*/
10561078
"missing-parameter": "Warning",

locale/en-us/script.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ DIAG_UNDEFINED_DOC_NAME =
114114
'Undefined type or alias `{}`.'
115115
DIAG_UNDEFINED_DOC_PARAM =
116116
'Undefined param `{}`.'
117+
DIAG_MISSING_GLOBAL_DOC_COMMENT =
118+
'Missing comment for global function `{}`.'
119+
DIAG_MISSING_GLOBAL_DOC_PARAM =
120+
'Missing @param annotation for parameter `{}` in global function `{}`.'
121+
DIAG_MISSING_GLOBAL_DOC_RETURN =
122+
'Missing @return annotation at index `{}` in global function `{}`.'
123+
DIAG_INCOMPLETE_SIGNATURE_DOC_PARAM =
124+
'Incomplete signature. Missing @param annotation for parameter `{}` in function `{}`.'
125+
DIAG_INCOMPLETE_SIGNATURE_DOC_RETURN =
126+
'Incomplete signature. Missing @return annotation at index `{}` in function `{}`.'
117127
DIAG_UNKNOWN_DIAG_CODE =
118128
'Unknown diagnostic code `{}`.'
119129
DIAG_CAST_LOCAL_TYPE =

locale/en-us/setting.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,12 @@ config.diagnostics['duplicate-doc-param'] =
373373
'Enable diagnostics for a duplicated param annotation name.'
374374
config.diagnostics['duplicate-set-field'] =
375375
'Enable diagnostics for setting the same field in a class more than once.'
376+
config.diagnostics['incomplete-signature-doc'] =
377+
'Incomplete @param or @return annotations for functions.'
376378
config.diagnostics['invisible'] =
377379
'Enable diagnostics for accesses to fields which are invisible.'
380+
config.diagnostics['missing-global-doc'] =
381+
'Missing annotations for globals! Global functions must have a comment and annotations for all parameters and return values.'
378382
config.diagnostics['missing-parameter'] =
379383
'Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.'
380384
config.diagnostics['missing-return'] =

locale/pt-br/script.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,17 @@ DIAG_UNDEFINED_DOC_NAME =
114114
'Tipo ou alias indefinido `{}`.'
115115
DIAG_UNDEFINED_DOC_PARAM =
116116
'Parâmetro indefinido `{}`.'
117-
DIAG_UNKNOWN_DIAG_CODE =
117+
DIAG_MISSING_GLOBAL_DOC_COMMENT = -- TODO: need translate!
118+
'Missing comment for global function `{}`.'
119+
DIAG_MISSING_GLOBAL_DOC_PARAM = -- TODO: need translate!
120+
'Missing @param annotation for parameter `{}` in global function `{}`.'
121+
DIAG_MISSING_GLOBAL_DOC_RETURN = -- TODO: need translate!
122+
'Missing @return annotation at index `{}` in global function `{}`.'
123+
DIAG_INCOMPLETE_SIGNATURE_DOC_PARAM = -- TODO: need translate!
124+
'Incomplete signature. Missing @param annotation for parameter `{}` in function `{}`.'
125+
DIAG_INCOMPLETE_SIGNATURE_DOC_RETURN = -- TODO: need translate!
126+
'Incomplete signature. Missing @return annotation at index `{}` in function `{}`.'
127+
DIAG_UNKNOWN_DIAG_CODE = -- TODO: need translate!
118128
'Código de diagnóstico desconhecido `{}`.'
119129
DIAG_CAST_LOCAL_TYPE = -- TODO: need translate!
120130
'This variable is defined as type `{def}`. Cannot convert its type to `{ref}`.'

locale/pt-br/setting.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,12 @@ config.diagnostics['duplicate-doc-param'] = -- TODO: need translate!
373373
'Enable diagnostics for a duplicated param annotation name.'
374374
config.diagnostics['duplicate-set-field'] = -- TODO: need translate!
375375
'Enable diagnostics for setting the same field in a class more than once.'
376+
config.diagnostics['incomplete-signature-doc'] = -- TODO: need translate!
377+
'Incomplete @param or @return annotations for functions.'
376378
config.diagnostics['invisible'] = -- TODO: need translate!
377379
'Enable diagnostics for accesses to fields which are invisible.'
380+
config.diagnostics['missing-global-doc'] = -- TODO: need translate!
381+
'Missing annotations for globals! Global functions must have a comment and annotations for all parameters and return values.'
378382
config.diagnostics['missing-parameter'] = -- TODO: need translate!
379383
'Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.'
380384
config.diagnostics['missing-return'] = -- TODO: need translate!

locale/zh-cn/script.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ DIAG_UNDEFINED_DOC_NAME =
114114
'未定义的类型或别名 `{}`。'
115115
DIAG_UNDEFINED_DOC_PARAM =
116116
'指向了未定义的参数 `{}`。'
117+
DIAG_MISSING_GLOBAL_DOC_COMMENT = -- TODO: need translate!
118+
'Missing comment for global function `{}`.'
119+
DIAG_MISSING_GLOBAL_DOC_PARAM = -- TODO: need translate!
120+
'Missing @param annotation for parameter `{}` in global function `{}`.'
121+
DIAG_MISSING_GLOBAL_DOC_RETURN = -- TODO: need translate!
122+
'Missing @return annotation at index `{}` in global function `{}`.'
123+
DIAG_INCOMPLETE_SIGNATURE_DOC_PARAM = -- TODO: need translate!
124+
'Incomplete signature. Missing @param annotation for parameter `{}` in function `{}`.'
125+
DIAG_INCOMPLETE_SIGNATURE_DOC_RETURN = -- TODO: need translate!
126+
'Incomplete signature. Missing @return annotation at index `{}` in function `{}`.'
117127
DIAG_UNKNOWN_DIAG_CODE =
118128
'未知的诊断代号 `{}`。'
119129
DIAG_CAST_LOCAL_TYPE =

0 commit comments

Comments
 (0)