Skip to content

Commit

Permalink
minor pylint suggested improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jul 1, 2021
1 parent 39503df commit 4d4a813
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/run-tests.yml
Expand Up @@ -71,10 +71,9 @@ jobs:
gdb -q -ex 'gef missing' -ex 'gef help' -ex 'gef config' -ex start -ex continue -ex quit /bin/pwd
- name: Run linter
continue-on-error: true
run: |
make lint
- name: Run Tests
run: |
make test
15 changes: 10 additions & 5 deletions Makefile
@@ -1,5 +1,10 @@
PYLINTRC_PATH := ./.pylintrc
PYLINT_RULES := --disable=all --enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode
NB_CORES := $(shell grep --count '^processor' /proc/cpuinfo)
PYLINT_DISABLE:= all
PYLINT_ENABLE := F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode
PYLINT_JOBS := $(NB_CORES)
PYLINT_SUGGEST_FIX := y
PYLINT_PARAMETERS := --disable=$(PYLINT_DISABLE) --enable=$(PYLINT_ENABLE) --jobs=$(PYLINT_JOBS) --suggestion-mode=$(PYLINT_SUGGEST_FIX) --exit-zero


test: testbins
@cp gef.py /tmp/gef.py
Expand All @@ -15,8 +20,8 @@ Test%: testbins
@rm -f /tmp/gef-*

testbins: tests/binaries/*.c
@$(MAKE) -C tests/binaries all
@$(MAKE) -j $(NB_CORES) -C tests/binaries all

lint:
python3 -m pylint $(PYLINT_RULES) gef.py
python3 -m pylint $(PYLINT_RULES) tests/*.py
python3 -m pylint $(PYLINT_PARAMETERS) gef.py
python3 -m pylint $(PYLINT_PARAMETERS) tests/*.py
7 changes: 3 additions & 4 deletions gef.py
Expand Up @@ -1922,8 +1922,6 @@ def is_conditional_branch(self, insn):

def is_branch_taken(self, insn):
mnemo, operands = insn.mnemonic, insn.operands
flags = dict((self.flags_table[k], k) for k in self.flags_table)
val = get_register(self.flag_register)
taken, reason = False, ""

if mnemo in {"cbnz", "cbz", "tbnz", "tbz"}:
Expand Down Expand Up @@ -3446,6 +3444,7 @@ def get_memory_alignment(in_bits=False):

def clear_screen(tty=""):
"""Clear the screen."""
global __gef_redirect_output_fd__
if not tty:
gdb.execute("shell clear -x")
return
Expand Down Expand Up @@ -8197,7 +8196,7 @@ def context_trace(self):
else:
try:
insn = next(gef_disassemble(pc, 1))
except gdb.MemoryError as e:
except gdb.MemoryError:
break
items.append(Color.redify("{} {}".format(insn.mnemonic, ", ".join(insn.operands))))

Expand Down Expand Up @@ -10527,7 +10526,7 @@ def do_invoke(self, argv):
try:
alias_to_remove = next(filter(lambda x: x._alias == argv[0], __aliases__))
__aliases__.remove(alias_to_remove)
except (ValueError, StopIteration) as e:
except (ValueError, StopIteration):
err("{0} not found in aliases.".format(argv[0]))
return
gef_print("You must reload GEF for alias removals to apply.")
Expand Down

0 comments on commit 4d4a813

Please sign in to comment.