@@ -9,6 +9,29 @@ use std::path::{Path, PathBuf};
99use std:: str:: FromStr ;
1010use std:: { cmp, env, fmt, fs, io, iter} ;
1111
12+ #[ rustfmt:: skip]
13+ const DEFAULT_DOC_VALID_IDENTS : & [ & str ] = & [
14+ "KiB" , "MiB" , "GiB" , "TiB" , "PiB" , "EiB" ,
15+ "DirectX" ,
16+ "ECMAScript" ,
17+ "GPLv2" , "GPLv3" ,
18+ "GitHub" , "GitLab" ,
19+ "IPv4" , "IPv6" ,
20+ "ClojureScript" , "CoffeeScript" , "JavaScript" , "PureScript" , "TypeScript" ,
21+ "NaN" , "NaNs" ,
22+ "OAuth" , "GraphQL" ,
23+ "OCaml" ,
24+ "OpenGL" , "OpenMP" , "OpenSSH" , "OpenSSL" , "OpenStreetMap" , "OpenDNS" ,
25+ "WebGL" ,
26+ "TensorFlow" ,
27+ "TrueType" ,
28+ "iOS" , "macOS" , "FreeBSD" ,
29+ "TeX" , "LaTeX" , "BibTeX" , "BibLaTeX" ,
30+ "MinGW" ,
31+ "CamelCase" ,
32+ ] ;
33+ const DEFAULT_BLACKLISTED_NAMES : & [ & str ] = & [ "foo" , "baz" , "quux" ] ;
34+
1235/// Holds information used by `MISSING_ENFORCED_IMPORT_RENAMES` lint.
1336#[ derive( Clone , Debug , Deserialize ) ]
1437pub struct Rename {
@@ -178,8 +201,10 @@ define_Conf! {
178201 ( msrv: Option <String > = None ) ,
179202 /// Lint: BLACKLISTED_NAME.
180203 ///
181- /// The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses
182- ( blacklisted_names: Vec <String > = [ "foo" , "baz" , "quux" ] . iter( ) . map( ToString :: to_string) . collect( ) ) ,
204+ /// The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses. The value
205+ /// `".."` can be used as part of the list to indicate, that the configured values should be appended to the
206+ /// default configuration of Clippy. By default any configuraction will replace the default value.
207+ ( blacklisted_names: Vec <String > = super :: DEFAULT_BLACKLISTED_NAMES . iter( ) . map( ToString :: to_string) . collect( ) ) ,
183208 /// Lint: COGNITIVE_COMPLEXITY.
184209 ///
185210 /// The maximum cognitive complexity a function can have
@@ -191,27 +216,14 @@ define_Conf! {
191216 ( cyclomatic_complexity_threshold: Option <u64 > = None ) ,
192217 /// Lint: DOC_MARKDOWN.
193218 ///
194- /// The list of words this lint should not consider as identifiers needing ticks
195- ( doc_valid_idents: Vec <String > = [
196- "KiB" , "MiB" , "GiB" , "TiB" , "PiB" , "EiB" ,
197- "DirectX" ,
198- "ECMAScript" ,
199- "GPLv2" , "GPLv3" ,
200- "GitHub" , "GitLab" ,
201- "IPv4" , "IPv6" ,
202- "ClojureScript" , "CoffeeScript" , "JavaScript" , "PureScript" , "TypeScript" ,
203- "NaN" , "NaNs" ,
204- "OAuth" , "GraphQL" ,
205- "OCaml" ,
206- "OpenGL" , "OpenMP" , "OpenSSH" , "OpenSSL" , "OpenStreetMap" , "OpenDNS" ,
207- "WebGL" ,
208- "TensorFlow" ,
209- "TrueType" ,
210- "iOS" , "macOS" , "FreeBSD" ,
211- "TeX" , "LaTeX" , "BibTeX" , "BibLaTeX" ,
212- "MinGW" ,
213- "CamelCase" ,
214- ] . iter( ) . map( ToString :: to_string) . collect( ) ) ,
219+ /// The list of words this lint should not consider as identifiers needing ticks. The value
220+ /// `".."` can be used as part of the list to indicate, that the configured values should be appended to the
221+ /// default configuration of Clippy. By default any configuraction will replace the default value. For example:
222+ /// * `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
223+ /// * `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
224+ ///
225+ /// Default list:
226+ ( doc_valid_idents: Vec <String > = super :: DEFAULT_DOC_VALID_IDENTS . iter( ) . map( ToString :: to_string) . collect( ) ) ,
215227 /// Lint: TOO_MANY_ARGUMENTS.
216228 ///
217229 /// The maximum number of argument a function or method can have
@@ -401,7 +413,21 @@ pub fn read(path: &Path) -> TryConf {
401413 Err ( e) => return TryConf :: from_error ( e) ,
402414 Ok ( content) => content,
403415 } ;
404- toml:: from_str ( & content) . unwrap_or_else ( TryConf :: from_error)
416+ match toml:: from_str :: < TryConf > ( & content) {
417+ Ok ( mut conf) => {
418+ extend_vec_if_indicator_present ( & mut conf. conf . doc_valid_idents , DEFAULT_DOC_VALID_IDENTS ) ;
419+ extend_vec_if_indicator_present ( & mut conf. conf . blacklisted_names , DEFAULT_BLACKLISTED_NAMES ) ;
420+
421+ conf
422+ } ,
423+ Err ( e) => TryConf :: from_error ( e) ,
424+ }
425+ }
426+
427+ fn extend_vec_if_indicator_present ( vec : & mut Vec < String > , default : & [ & str ] ) {
428+ if vec. contains ( & ".." . to_string ( ) ) {
429+ vec. extend ( default. iter ( ) . map ( ToString :: to_string) ) ;
430+ }
405431}
406432
407433const SEPARATOR_WIDTH : usize = 4 ;
0 commit comments