Function fill_loc_db_with_symbols
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def fill_loc_db_with_symbols(elf, loc_db, base_addr=0):
"""Parse the miasm.loader's ELF @elf to extract symbols, and fill the LocationDB
instance @loc_db with parsed symbols.
The ELF is considered mapped at @base_addr
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function vm_load_elf
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def vm_load_elf(vm, fdata, name="", base_addr=0, loc_db=None, apply_reloc=False,
**kargs):
"""
Very dirty elf loader
TODO XXX: implement real loader
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function apply_reloc_x86
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def apply_reloc_x86(elf, vm, section, base_addr, loc_db):
"""Apply relocation for x86 ELF contained in the section @section
@elf: miasm.loader's ELF instance
@vm: VmMngr instance
@section: elf's section containing relocation to perform
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File elf.py
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
import struct
from collections import defaultdict
from future.utils import viewitems
Function preload_elf
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def preload_elf(vm, e, runtime_lib, patch_vm_imp=True, loc_db=None):
# XXX quick hack
fa = get_import_address_elf(e)
dyn_funcs = {}
for (libname, libfunc), ads in viewitems(fa):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function vm_load_elf
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_load_elf(vm, fdata, name="", base_addr=0, loc_db=None, apply_reloc=False,
Function preload_elf
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def preload_elf(vm, e, runtime_lib, patch_vm_imp=True, loc_db=None):
Function apply_reloc_x86
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_reloc_x86(elf, vm, section, base_addr, loc_db):
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (elf.size, reloc.type) in [
(64, elf_csts.R_X86_64_RELATIVE),
(64, elf_csts.R_X86_64_IRELATIVE),
(32, elf_csts.R_386_RELATIVE),
(32, elf_csts.R_386_IRELATIVE),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 39.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
elif (elf.size, reloc.type) in [
(64, elf_csts.R_X86_64_GLOB_DAT),
(64, elf_csts.R_X86_64_JUMP_SLOT),
(32, elf_csts.R_386_JMP_SLOT),
(32, elf_csts.R_386_GLOB_DAT),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 39.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76