[go: nahoru, domu]

Switch tools/cygprofile to PyLint 2.7

This change makes tools/cygprofile/PRESUBMIT.py run PyLint 2.7 instead
of the default, PyLint 1.5. It also fixes any issues found by PyLint
2.7.

This change also makes run_tests run on Python 3, and fixes any issues
resulting from the transition.

Most of the changes are straightforward fixes recommended by PyLint,
but there are a few that warrant explanation:
* orderfile_generator_backend.py:758: _CLOUD_STORAGE_BUCKET_FOR_DEBUG
  did not exist, and another class in the same file set its same-named
  member to None, so I couldn't find a reasonable value for it. I
  therefore removed it from the `upload_location` path altogether.
* orderfile_generator_backend.py:971: ClankCompiler had no
  `manual_libname` member. As far as I can tell, it's only a member of
  `options` (which is created by parsing the script's args). Because
  of that, I assumed this was meant to be retrieved from `options`.
* process_profiles.py:641: the function SortByTimestamp() did not
  exist, but __init() seems to sort by timestamp already, so I removed
  the line altogether.

The full list of errors found by PyLint 2.7 were as follows:

************* Module test_utils
test_utils.py:20:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
test_utils.py:26:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module cygprofile_utils
cygprofile_utils.py:11:0: R0205: Class 'WarningCollector' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
************* Module check_orderfile
check_orderfile.py:57:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
************* Module cluster
cluster.py:21:0: R0205: Class 'Clustering' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
cluster.py:72:2: R0205: Class '_Cluster' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
cluster.py:348:0: R1721: Unnecessary use of a comprehension (unnecessary-comprehension)
cluster.py:393:0: R1721: Unnecessary use of a comprehension (unnecessary-comprehension)
cluster.py:413:2: R1705: Unnecessary "else" after "return" (no-else-return)
************* Module compare_orderfiles
compare_orderfiles.py:45:13: R1714: Consider merging these comparisons with "in" to "symbol_name not in ('*', '.text')" (consider-using-in)
************* Module process_profiles
process_profiles.py:27:2: R1705: Unnecessary "else" after "return" (no-else-return)
process_profiles.py:34:0: R0205: Class 'SymbolOffsetProcessor' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
process_profiles.py:327:0: R0205: Class 'ProfileManager' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
process_profiles.py:366:2: R0205: Class 'AnnotatedOffset' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
process_profiles.py:393:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
process_profiles.py:396:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
process_profiles.py:404:2: R0205: Class '_RunGroup' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
process_profiles.py:641:2: E1101: Instance of 'ProfileManager' has no 'SortByTimestamp' member (no-member)
process_profiles.py:651:20: E1101: Instance of 'SymbolOffsetProcessor' has no 'GetReachedOffsetsFromDumps' member; maybe 'GetReachedOffsetsFromDump'? (no-member)
************* Module cyglog_to_orderfile_unittest
cyglog_to_orderfile_unittest.py:34:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
************* Module profile_android_startup
profile_android_startup.py:46:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
profile_android_startup.py:79:0: R0205: Class 'WprManager' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
profile_android_startup.py:177:0: R0205: Class 'AndroidProfileTool' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
************* Module cyglog_to_orderfile
cyglog_to_orderfile.py:27:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
cyglog_to_orderfile.py:45:0: R0205: Class 'ObjectFileProcessor' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
cyglog_to_orderfile.py:137:0: R0205: Class 'OffsetOrderfileGenerator' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
cyglog_to_orderfile.py:197:4: R1705: Unnecessary "elif" after "return" (no-else-return)
************* Module orderfile_generator_backend
orderfile_generator_backend.py:65:4: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
orderfile_generator_backend.py:99:2: R1705: Unnecessary "else" after "return" (no-else-return)
orderfile_generator_backend.py:158:0: R0205: Class 'StepRecorder' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
orderfile_generator_backend.py:238:0: R0205: Class 'ClankCompiler' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
orderfile_generator_backend.py:354:0: R0205: Class 'OrderfileUpdater' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
orderfile_generator_backend.py:455:0: R0205: Class 'OrderfileGenerator' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
orderfile_generator_backend.py:520:12: R1716: Simplify chained comparison between the operands (chained-comparison)
orderfile_generator_backend.py:759:10: E1101: Instance of 'OrderfileGenerator' has no '_CLOUD_STORAGE_BUCKET_FOR_DEBUG' member (no-member)
orderfile_generator_backend.py:971:10: E1101: Instance of 'ClankCompiler' has no 'manual_libname' member (no-member)

The errors printed by run_tests after moving to Python 3 were:

======================================================================
ERROR: testBasicParsing (symbol_extractor_unittest.TestLlvmBitcodeSymbolExtractor)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/jessemckenna/chromium/src/tools/cygprofile/symbol_extractor_unittest.py", line 25, in testBasicParsing
    symbol_names = symbol_extractor._SymbolInfosFromLlvmNm(lines)
File "/usr/local/google/home/jessemckenna/chromium/src/tools/cygprofile/symbol_extractor.py", line 221, in _SymbolInfosFromLlvmNm
    line = line.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

======================================================================
ERROR: testSymbolInfosFromStream (symbol_extractor_unittest.TestSymbolInfosFromStream)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/google/home/jessemckenna/chromium/src/tools/cygprofile/symbol_extractor_unittest.py", line 163, in testSymbolInfosFromStream
    symbol_infos = symbol_extractor._SymbolInfosFromStream(lines)
File "/usr/local/google/home/jessemckenna/chromium/src/tools/cygprofile/symbol_extractor.py", line 153, in _SymbolInfosFromStream
    symbol_info = _FromObjdumpLine(line.decode('utf-8').rstrip('\n'))
AttributeError: 'str' object has no attribute 'decode'

----------------------------------------------------------------------

This change was tested by running
`git cl presubmit --force --files "tools/cygprofile/*"` on Linux,
which now completes without errors.

Bug: 1333589
Change-Id: I29764c8ed0d680795d0a557b2ba2ec09adf65cd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3703235
Reviewed-by: Benoit Lize <lizeb@chromium.org>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Cr-Commit-Position: refs/heads/main@{#1015417}
13 files changed
tree: 4c48b09a2c299d58dfb72f6ad58abb63de46109d
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. courgette/
  16. crypto/
  17. dbus/
  18. device/
  19. docs/
  20. extensions/
  21. fuchsia/
  22. fuchsia_web/
  23. gin/
  24. google_apis/
  25. google_update/
  26. gpu/
  27. headless/
  28. infra/
  29. ios/
  30. ipc/
  31. media/
  32. mojo/
  33. native_client_sdk/
  34. net/
  35. pdf/
  36. ppapi/
  37. printing/
  38. remoting/
  39. rlz/
  40. sandbox/
  41. services/
  42. skia/
  43. sql/
  44. storage/
  45. styleguide/
  46. testing/
  47. third_party/
  48. tools/
  49. ui/
  50. url/
  51. weblayer/
  52. .clang-format
  53. .clang-tidy
  54. .eslintrc.js
  55. .git-blame-ignore-revs
  56. .gitattributes
  57. .gitignore
  58. .gn
  59. .mailmap
  60. .rustfmt.toml
  61. .vpython
  62. .vpython3
  63. .yapfignore
  64. AUTHORS
  65. BUILD.gn
  66. CODE_OF_CONDUCT.md
  67. codereview.settings
  68. DEPS
  69. DIR_METADATA
  70. ENG_REVIEW_OWNERS
  71. LICENSE
  72. LICENSE.chromium_os
  73. OWNERS
  74. PRESUBMIT.py
  75. PRESUBMIT_test.py
  76. PRESUBMIT_test_mocks.py
  77. README.md
  78. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure .

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.