From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 18D8356A9A0; Tue, 8 Aug 2023 22:43:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 18D8356A9A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1691523832; bh=8uq98lXWWxKbDf2LU67CiF4b8qAbe9SKXXjCdnvhGqo=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PAgJbXUjBjz1lmSoVzppMMA0A3gnq33yKnOyGr7p0rT7GFcbBPW46235N1gphk25H 4s8MwiKXfrd5NBkcHYL6ilh/7XnJesGGkmCe4YCxaAmco7FzFeShOjxwKZiq8RfMjE jIYptlQUKQ2/FDUiLnjDXDI+LLzfKZjieJq1OJOw= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [95.163.41.86]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6729D56A9A0 for ; Tue, 8 Aug 2023 22:43:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6729D56A9A0 Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1qTScO-002MqX-1u; Tue, 08 Aug 2023 22:43:49 +0300 Date: Tue, 8 Aug 2023 19:29:47 +0000 To: Maxim Kokryashkin Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD969E04B5EED670DC836E8CADCCFC7EB90264FE23C7F795239182A05F5380850407B25A9C504365FB29BE9CD942FB8537EB7A883813BA122E5531CD472D82A5714 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71B1B5393BB9C1313EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379108F895B68B2FFD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8FB62786431287BF045BE18CDA5D2BBCD117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520CCD848CCB6FE560CCB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEB28585415E75ADA93D5BA627BF9F2FCFD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE367F1C1C3ABB44F3A03F1AB874ED89028C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637FB177F6A8366F17BEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A53B31E0CD692399FFB48F8DEAE81AD17A954429FA27D0E806F87CCE6106E1FC07E67D4AC08A07B9B0DB8A315C1FF4794DBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34DFB7A809FB537087B08664573282C9FCC398670A6B8F8A973FFCE73F3ED432E08B30A35138665C3C1D7E09C32AA3244C916A34F0387F6F8CF9D6F4FDECC7BEBA8A6D4CC6FBFAC251BAD658CF5C8AB4025DA084F8E80FEBD376A4ED3E9341DC2FCD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojUzxoxvtYX2pNlx7BNT7uBA== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D531DE90261C1BCF2C2FA751C666416967F8F5FE0F713CDDC9372326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 15/15] test: run flake8 static analysis via CMake X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Max, Thanks for your review! See my answers inline. On 04.08.23, Maxim Kokryashkin wrote: > Hi, Igor! > Thanks for the patch! > > Aside from comments left by Sergey, please consider a few of mine. > > On Thu, Aug 03, 2023 at 07:30:40AM +0000, Igor Munkin wrote: > > This patch introduces a separate target to run flake8 against all Python > > scripts within LuaJIT repository (i.e. debugger extensions). There are > > some tweaks in .flake8rc regarding our style: one can find more info in > > the config file. > > > > The new target is a dependency for the new target, that > > joins both luacheck and flake8 linter runs. CI job with linters is > > adjusted respectively. > > > > Signed-off-by: Igor Munkin > > --- > > .flake8rc | 12 ++++++++++++ > > .github/workflows/lint.yml | 4 ++-- > > test/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ > > 3 files changed, 42 insertions(+), 2 deletions(-) > > create mode 100644 .flake8rc > > > > diff --git a/.flake8rc b/.flake8rc > > new file mode 100644 > > index 00000000..b6f7ad48 > > --- /dev/null > > +++ b/.flake8rc > > @@ -0,0 +1,12 @@ > > +[flake8] > > +extend-ignore = > > + # TODO: I have no idea, how to fix this. flake8 suggests nothing > > + # (like clang-format or checkpatch.pl do). Help needed. > > + E131, > > + # TODO: I have no idea, how to fix this. flake8 suggests nothing > > + # (like clang-format or checkpatch.pl do). Help needed. > > + E501, > I dont't think we should disable the continuation line alignment rule (E131), > which has explanation in the docs[1] and the line length limit[2] (E501), which is > easily fixed. *"I have no idea" why I decided to write that E131 is hard to fix...* Maybe it's a brain damage as a result of solar flare, dunno. All in all, I've marked all spots reported by flake8 with # noqa label and here is why: All of the "misaligned" places are located deeply inside a cascade of the calls and list comprehensions, so indenting the tail of the comprehension with the same indent level as its beginning makes the code barely readable at least for me. Yes, I have read enough Python code and recently faced some sources with the "right" indentation: it looks unreadable as fuck, since the only difference between prefix and postfix "statement" is the freaking colon. IMHO the current indentation emphases the fact that this is a oneline statement split into two lines due to the width limits. I know that syntax error will occur if prefix variant is used instead of postfix and vice versa, but we're talking about code formatting and readability. I removed the global suppression and added inline suppressions in scope of the separate commit (will send in reply to this message). As for E501, I also rewrote some parts and finally fixed all occurrences (will also send the patch in reply to this message). New CI results here: https://github.com/tarantool/luajit/commit/f9c3849. The diff for .flake8rc as a result of the aforementioned changes: ================================================================================ diff --git a/.flake8rc b/.flake8rc index b6f7ad48..13e6178f 100644 --- a/.flake8rc +++ b/.flake8rc @@ -1,12 +1,5 @@ [flake8] extend-ignore = - # TODO: I have no idea, how to fix this. flake8 suggests nothing - # (like clang-format or checkpatch.pl do). Help needed. - E131, - # TODO: I have no idea, how to fix this. flake8 suggests nothing - # (like clang-format or checkpatch.pl do). Help needed. - E501, # XXX: Suppress F821, since we have autogenerated names for # 'ptr' type complements in luajit_lldb.py. F821 -max-line-length = 80 ================================================================================ > > + # XXX: Suppress F821, since we have autogenerated names for > > + # 'ptr' type complements in luajit_lldb.py. > > + F821 > > +max-line-length = 80 > > diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt > > index 47296a22..17ac5cac 100644 > > --- a/test/CMakeLists.txt > > +++ b/test/CMakeLists.txt > > @@ -42,6 +42,34 @@ else() > > ) > > endif() > > > > +find_program(FLAKE8 flake8) > > +if(FLAKE8) > > + get_filename_component(FLAKE8_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH) > > + set(FLAKE8_RC ${FLAKE8_SOURCE_DIR}/.flake8rc) > > + file(GLOB_RECURSE FLAKE8_DEPS ${FLAKE8_SOURCE_DIR}/*.py) > > + add_custom_target(${PROJECT_NAME}-flake8 > > + DEPENDS ${FLAKE8_DEPS} > > + ) > > + add_custom_command(TARGET ${PROJECT_NAME}-flake8 > > + COMMENT "Running flake8 static analysis" > > + COMMAND > > + ${FLAKE8} ${FLAKE8_DEPS} > > + --config ${FLAKE8_RC} > > + --jobs ${CMAKE_BUILD_PARALLEL_LEVEL} > > + WORKING_DIRECTORY ${FLAKE8_SOURCE_DIR} > > + ) > I suggest moving this logic to a separate cmake module. It will > make the test/CMakeLists.txt cleaner and more readable. Nice idea, thanks! However, I suggest to move it in scope of the series integrating CTest (along with luacheck part). Does this work for you? > > +else() > > + add_custom_target(${PROJECT_NAME}-flake8) > > + add_custom_command(TARGET ${PROJECT_NAME}-flake8 > > + COMMENT "`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy" > > + ) > > +endif() > > + > > +add_custom_target(${PROJECT_NAME}-lint DEPENDS > > + ${PROJECT_NAME}-luacheck > > + ${PROJECT_NAME}-flake8 > > +) > > + > > set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]") > > separate_arguments(LUAJIT_TEST_COMMAND) > > > > -- > > 2.30.2 > > > [1]: https://www.flake8rules.com/rules/E131.html > [2]: https://www.flake8rules.com/rules/E501.html > > Best regards, > Maxim Kokryashkin -- Best regards, IM