File msilib.py
has 601 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Microsoft Installer Library
# (C) 2003 Martin v. Loewis
import win32com.client.gencache
import win32com.client
Function gen_sequence
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def gen_sequence(destpath, msipath):
dir = os.path.dirname(destpath)
d = MakeInstaller()
seqmsi = d.OpenDatabase(msipath,
win32com.client.constants.msiOpenDatabaseModeReadOnly)
- 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 make_short
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def make_short(self, file):
file = re.sub(r'[\?|><:/*"+,;=\[\]]', '_', file) # restrictions on short names
parts = file.split(".")
if len(parts)>1:
suffix = parts[-1].upper()
- 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 sql
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def sql(self):
fields = []
keys = []
self.fields.sort()
fields = [None]*len(self.fields)
- 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 gen_schema
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def gen_schema(destpath, schemapath):
d = MakeInstaller()
schema = d.OpenDatabase(schemapath,
win32com.client.constants.msiOpenDatabaseModeReadOnly)
- 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 commit
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def commit(self, db):
self.file.close()
try:
os.unlink(self.name+".cab")
except OSError:
- 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 __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, db, name, x, y, w, h, attr, title, first, default, cancel):
Function control
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def control(self, name, type, x, y, w, h, attr, prop, text, next, help):
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, db, id, title, desc, display, level = 1,
Function radiogroup
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def radiogroup(self, name, x, y, w, h, attr, prop, text, next):
Function checkbox
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def checkbox(self, name, x, y, w, h, attr, prop, text, next):
Function add_data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_data(db, table, values):
d = MakeInstaller()
v = db.OpenView("SELECT * FROM `%s`" % table)
count = v.ColumnInfo(0).FieldCount
r = d.CreateRecord(count)
- 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 pushbutton
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def pushbutton(self, name, x, y, w, h, attr, text, next):
Function change_sequence
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
"Change the sequence number of an action in a sequence list"
for i in range(len(seq)):
if seq[i][0] == action:
if cond is _Unspecified:
- 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 init_database
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def init_database(name, schema,
Function text
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def text(self, name, x, y, w, h, attr, text):
Function add
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def add(self, name, x, y, w, h, text, value = None):
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None):
Avoid deeply nested control flow statements. Open
if table == "Binary":
fname = rec[0]+".bin"
open(os.path.join(dir,fname),"wb").write(bytes)
rec.append(Binary(fname))
else:
Function bitmap
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def bitmap(self, name, x, y, w, h, text):
Function start_component
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
"""Add an entry to the Component table, and make this component the current for this
directory. If no component name is given, the directory name is used. If no feature
is given, the current feature is used. If no flags are given, the directory's default
flags are used. If no keyfile is given, the KeyPath is left null in the Component
- 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 start_component
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
Function line
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def line(self, name, x, y, w, h):
Similar blocks of code found in 4 locations. Consider refactoring. Open
machine = struct.unpack("<H", header[pe_offset+4:pe_offset+6])[0]
- 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 38.
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
def condition(self, action, condition):
add_data(self.dlg.db, "ControlCondition",
[(self.dlg.name, self.name, action, condition)])
- 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 34.
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
def mapping(self, ev, attr):
add_data(self.dlg.db, "EventMapping",
[(self.dlg.name, self.name, ev, attr)])
- 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 34.
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