Inline method refactoring changes variables names after applying the transformation
メンテナーはふだん 7 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start from the Inline Method refactoring applied to the nested RL function in the reproduction snippet. The output renames locals with a __0__ and __1__ prefix and drops the parameter binding, so look at how the inliner renames and substitutes local names. Reproduce by running the refactoring on the snippet. Done means the output matches the expected code, with no prefixed names and the loop variables kept intact.
索引モデルが issue の本文から書いたものです。
説明
Inline method refactoring changes field signatures and generates uninitialized variables
Steps to reproduce the behavior:
- Code before refactoring:
def _calculate_tk(source):
def RL(a, b):
for c in range(0, len(b) - 2, 3):
xa = a & ((1 << 32) - 1)
d = ord(b[c + 2]) - 87 if b[c + 2] >= 'a' else int(b[c + 2])
d = xa >> d if b[c + 1] == '+' else xa << d
a = a + d & 4294967295 if b[c] == '+' else a ^ d
return (a & ((1 << (32 - 1)) - 1)) - (a & (1 << (32 - 1)))
b = 406398
d = source.encode('utf-8')
a = b
for di in d:
a = RL(a + di, "+-a^+6")
a = RL(a, "+-3^+b+-f")
return '{0:d}.{1:d}'.format(a, a ^ b)
-
Apply the Inline Method refactoring to '_calculate_tk.RL'
-
Expected code after refactoring:
def _calculate_tk(source):
b = 406398
d = source.encode('utf-8')
a = b
for di in d:
for c in range(0, len("+-a^+6") - 2, 3):
xa = a + di & ((1 << 32) - 1)
d = ord("+-a^+6"[c + 2]) - 87 if "+-a^+6"[c + 2] >= 'a' else int("+-a^+6"[c + 2])
d = xa >> d if "+-a^+6"[c + 1] == '+' else xa << d
a = a + di + d & 4294967295 if "+-a^+6"[c] == '+' else a + di ^ d
a = (a + di & ((1 << (32 - 1)) - 1)) - (a + di & (1 << (32 - 1)))
for c in range(0, len("+-3^+b+-f") - 2, 3):
xa = a & ((1 << 32) - 1)
d = ord("+-3^+b+-f"[c + 2]) - 87 if "+-3^+b+-f"[c + 2] >= 'a' else int("+-3^+b+-f"[c + 2])
d = xa >> d if "+-3^+b+-f"[c + 1] == '+' else xa << d
a = a + d & 4294967295 if "+-3^+b+-f"[c] == '+' else a ^ d
a = (a & ((1 << (32 - 1)) - 1)) - (a & (1 << (32 - 1)))
return '{0:d}.{1:d}'.format(a, a ^ b)
- The result of the program after applied transformation:
def _calculate_tk(source):
b = 406398
d = source.encode('utf-8')
a = b
for di in d:
for __0__c in range(0, len("+-a^+6") - 2, 3):
__0__xa = __0__a + di & ((1 << 32) - 1)
__0__d = ord("+-a^+6"[__0__c + 2]) - 87 if "+-a^+6"[__0__c + 2] >= 'a' else int("+-a^+6"[__0__c + 2])
__0__d = __0__xa >> __0__d if "+-a^+6"[__0__c + 1] == '+' else __0__xa << __0__d
__0__a = __0__a + di + __0__d & 4294967295 if "+-a^+6"[__0__c] == '+' else __0__a + di ^ __0__d
a = (__0__a + di & ((1 << (32 - 1)) - 1)) - (__0__a + di & (1 << (32 - 1)))
for __1__c in range(0, len("+-3^+b+-f") - 2, 3):
__1__xa = __1__a & ((1 << 32) - 1)
__1__d = ord("+-3^+b+-f"[__1__c + 2]) - 87 if "+-3^+b+-f"[__1__c + 2] >= 'a' else int("+-3^+b+-f"[__1__c + 2])
__1__d = __1__xa >> __1__d if "+-3^+b+-f"[__1__c + 1] == '+' else __1__xa << __1__d
__1__a = __1__a + __1__d & 4294967295 if "+-3^+b+-f"[__1__c] == '+' else __1__a ^ __1__d
a = (__1__a & ((1 << (32 - 1)) - 1)) - (__1__a & (1 << (32 - 1)))
return '{0:d}.{1:d}'.format(a, a ^ b)
- 主要言語
- Python
- スター
- 2.2k
- フォーク
- 197
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-rope/rope のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
python-rope/rope#927 ·
メンテナーはふだん 7 日以内に返信
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only region対応中かも @aliassar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-rope/rope#926 ·
メンテナーはふだん 7 日以内に返信
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offset対応中かも @sean0407 が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
python-rope/rope#913 ·
メンテナーはふだん 7 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
python-rope/rope#925 ·
メンテナーはふだん 7 日以内に返信
-
Extract method/variable and introduce parameter don't check whether the new name is already in useオープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
python-rope/rope#924 ·
メンテナーはふだん 7 日以内に返信
python-rope/rope の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
QuantConnect/Documentation#2838 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · コメント 1 件 ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultオープンbug pkg:harness
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pydantic/pydantic-ai#12405 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
good first issue help wanted
難易度 1/5 1時間未満 初心者へのやさしさ 82/100