Skip to content

5. Verified modernisation ​

An automatic fix is only as good as the evidence that it changes nothing. fobis modernize applies the fixable rules in a scratch copy of the project, builds it, runs the tests (and the cases when there are), and keeps a fix only when they pass exactly as on an untouched copy:

console
$ fobis modernize
modernize: base copy in ~/tmp/fobis-modernize-yeebvuhj
modernize: checking MDN021, OBS005, OBS011
fixes found:
  MDN021: 1 edit(s) in 1 file(s)
  OBS005: 1 edit(s) in 1 file(s)
  OBS011: 6 edit(s) in 1 file(s)
check [MDN021, OBS005, OBS011]: PASS (evidence: tests)
    build: ok
    tests: ok
verified: MDN021, OBS005, OBS011
applied: nothing (use --apply)

When the whole set fails, each rule is tried alone, so a wrong fix is isolated. Nothing is written without --apply:

console
$ fobis modernize --apply
modernize: base copy in ~/tmp/fobis-modernize-h6xnq01a
modernize: checking MDN021, OBS005, OBS011
fixes found:
  MDN021: 1 edit(s) in 1 file(s)
  OBS005: 1 edit(s) in 1 file(s)
  OBS011: 6 edit(s) in 1 file(s)
check [MDN021, OBS005, OBS011]: PASS (evidence: tests)
    build: ok
    tests: ok
verified: MDN021, OBS005, OBS011
applied: src/romberg.f
console
$ git diff --stat
 src/romberg.f | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
console
$ fobis lint --select OBS005,OBS011,MDN021
0 finding(s) in 10 file(s)

Without tests or cases the only evidence is the build, which does not prove that a fix keeps the results: then --apply needs --unverified too.

What you learned

fobis modernize, --apply, what counts as evidence. Reference: verified modernisation.

Next: 6. C and Python bindings.