Auto merge of #9252 - Metaswitch:use-deprecated-config, r=Jarcho

Read and use deprecated configuration (as well as emitting a warning)

Original change written by `@flip1995` I've simply rebased to master and fixed up the formatting/tests.  This change teaches the configuration parser which config key replaced a deprecated key and attempts to populate the latter from the former.  If both keys are provided this fails with a duplicate key error (rather than attempting to guess which the user intended).

Currently this on affects `cyclomatic-complexity-threshold` -> `cognitive-complexity-threshold` but will also be used in #8974 to handle `blacklisted-names` -> `disallowed-names`.

```
changelog: deprecated configuration keys are still applied as if they were provided as their non-deprecated name.
```

- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`
This commit is contained in:
bors
2022-07-29 00:54:10 +00:00
8 changed files with 69 additions and 13 deletions

View File

@@ -486,7 +486,7 @@ pub fn read_conf(sess: &Session) -> Conf {
},
};
let TryConf { conf, errors } = utils::conf::read(&file_name);
let TryConf { conf, errors, warnings } = utils::conf::read(&file_name);
// all conf errors are non-fatal, we just use the default conf in case of error
for error in errors {
sess.err(&format!(
@@ -496,6 +496,15 @@ pub fn read_conf(sess: &Session) -> Conf {
));
}
for warning in warnings {
sess.struct_warn(&format!(
"error reading Clippy's configuration file `{}`: {}",
file_name.display(),
format_error(warning)
))
.emit();
}
conf
}