#7344 Fix warnings and errors found by LGTM static code analyzer
Opened by cheimes. Modified

LGTM (looks good to me) is a static code analyzer for Open Source projects that can analyse Python, JS, and other code. Static code analysis can find errors in code without actually executing it. It's very useful to find bugs in lines that are rarely executed.

https://lgtm.com/projects/g/freeipa/freeipa/ lists about 120 open errors and 80 open warnings for FreeIPA. Most errors look legit and should be addressed.


First patch: https://github.com/freeipa/freeipa/pull/1429

Metadata Update from @cheimes:
- Issue assigned to cheimes

master:

  • cae2d99f89d940d2554a82f8ca1bbfeb1f46d336 LGTM: Silence unmatchable dollar
  • 1ed4461f338e456837bb074602dd76e0f0bd5b10 LGTM: Use of exit() or quit()
  • a4f36eec0ac741f0050ae15928f101932e8aff4a LGTM: Name unused variable in loop
  • d3f43a673771aa40365ac1b34dc21e4e22d4a7cb LGTM: Membership test with a non-container
  • de616888d5718532dbb8e66ed3f6c698cdf1e79c LGTM: Fix exception in permission_del
  • dc599e0797572810a836b84f138f520672f33e94 LGTM: Remove redundant assignment
  • 73ee9ff40e7026ce264d0445db96fa16a33ed589 LGTM: Fix multiple use before assignment
  • f60b2c590684c8ffc2c6ce2efa7a99f0193f42a1 LGTM: raise handle_not_found()
  • 5d02c6aaeb893bf382037d34dc67e6293365c702 LGTM: Use explicit string concatenation
  • beb6d74b81eae9965ddc031db1a3826c01d59d30 LGTM: unnecessary else in for loop

ipa-4-6:

  • 128a1279647e997c42637173087d4ce9d8884d5d LGTM: Silence unmatchable dollar
  • c7fb8a1710895587099a72cc8cc1d60e6182a803 LGTM: Use of exit() or quit()
  • 298fb680b6c628193dfbff5c253b02621c67e870 LGTM: Name unused variable in loop
  • 16eb0a954eadb50602aeb7dd1e07d66421209e8e LGTM: Membership test with a non-container
  • 4608637822e96aa114b49099704b22874e1e2dc6 LGTM: Fix exception in permission_del
  • 62f8f0203259c00b27dc5416d6b8a7c8627183f2 LGTM: Remove redundant assignment
  • 22a8aba580912e53fa0488cae2482a2475aea56b LGTM: Fix multiple use before assignment
  • 1472597c20164b0e27464e8f8bc4d62db0f176d0 LGTM: raise handle_not_found()
  • 8296adaeb53d34259afcbab3607a4dcb14834f84 LGTM: Use explicit string concatenation
  • 7047d6c252dc9004d6cd600db181891b4ca4bb88 LGTM: unnecessary else in for loop

The first batch of fixes closed about 90 warnings and errors. FreeIPA is now down to 54 errors and 78 warnings.

Metadata Update from @rcritten:
- Issue priority set to: normal
- Issue set to the milestone: FreeIPA 4.7

Metadata Update from @rcritten:
- Issue set to the milestone: FreeIPA 4.7.1 (was: FreeIPA 4.7)

FreeIPA 4.7 has been released, moving to FreeIPA 4.7.1 milestone

Metadata Update from @rcritten:
- Issue set to the milestone: FreeIPA 4.7.2 (was: FreeIPA 4.7.1)

FreeIPA 4.7.1 has been released, moving to FreeIPA 4.7.2 milestone

There are still a few warnings/suggestions. I skimmed them and most were bogus but probably worth a closer look.

Metadata