Inline method refactoring changes variables names after applying the transformation
I maintainer di solito rispondono entro 7 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 34/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 197
- Merge medio
- 2g 13h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-rope/rope
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
python-rope/rope#927 ·
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
python-rope/rope#926 ·
I maintainer di solito rispondono entro 7 giorni
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetForse già presa @sean0407 l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
python-rope/rope#913 ·
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
python-rope/rope#925 ·
I maintainer di solito rispondono entro 7 giorni
-
Extract method/variable and introduce parameter don't check whether the new name is already in useAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
python-rope/rope#924 ·
I maintainer di solito rispondono entro 7 giorni
Tutte le issue di python-rope/rope
Issue simili
-
New InternshipApertanew_internship
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
get_graph warns that the oneway column is missing when no way has a oneway tagForse già presa @HTenkanen l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cython/cython#8110 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
fix: security 🔐 style: article/section 📝 system: data-mgmt 🗃️ system: security 🔐 system: software 💻
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
uabrc/uabrc.github.io#1267 ·
-
Link Checker ReportApertaBot Type: Bug Type: Documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno