houtianze/bypy

View on GitHub

Showing 218 of 218 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            pars = {
                'method' : 'list',
                'path' : remotepath,
                'by' : 'name',
                'order' : 'asc',
Severity: Minor
Found in bypy/bypy.py and 1 other location - About 30 mins to fix
bypy/bypy.py on lines 1370..1375

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 32.

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

Further Reading

Function share has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def share(self, path = '.', sharepath = '/', islocal = True, fast = False):
        islocal = str2bool(islocal)
        fast = str2bool(fast)
        if islocal:
            lpath = path
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _select_fastest_mirror_act has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _select_fastest_mirror_act(self, r, args):
        pr("Selecting fastest mirror")
        j = r.json()
        self.pv("List of PCS mirrors:\n" + pprint.pformat(j))
        if 'path' not in j:
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _store has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _store(self, info, path, value):
        cached.dirty = True
        info['size'] = getfilesize(path)
        info['mtime'] = getfilemtime_int(path)
        info[self.f.__name__] = value
Severity: Minor
Found in bypy/cached.py - About 25 mins to fix

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 _share_local has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _share_local(self, lpath, rpath, fast):
        if not os.path.exists(lpath):
            perr("Local path '{}' does not exist.".format(lpath))
            return const.EParameter

Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _syncup_local_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _syncup_local_one(self, rpath, localdir, l):
        result = const.ENoError
        t = l[0]
        p = l[1]
        #lcpath = os.path.join(localdir, p) # local complete path
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _print_error_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _print_error_json(self, r):
        try:
            dj = r.json()
            if 'error_code' in dj and 'error_msg' in dj:
                ec = dj['error_code']
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _proceed_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _proceed_list(self, walkresult, remotepath, dirjs, filejs, args):
        result = walkresult
        fmt = args
        # cutfront = const.AppPcsPathLen
        cutfront = len(remotepath) + 1
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _syncdown_single has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _syncdown_single(self, rpath, localdir, compare_result):
        result = const.ENoError
        same, diff, local, remote = compare_result
        # clear the way
        for d in diff:
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _syncup_delete_remote has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _syncup_delete_remote(self, rpath, remote):
        result = const.ENoError
        # i think the list is built top-down, so directories appearing later are either
        # children or another set of directories
        pp = '\\' # previous path, setting to '\\' make sure it won't be found in the first step
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _compare_size has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _compare_size(self, lsize, rjson):
        if 'size' in rjson:
            rsize = rjson['size']
            if lsize == rsize:
                return 0
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def help(command): # this comes first to make it easy to spot
        ''' Usage: help <command> - provide some information for the command '''
        for i, v in ByPy.__dict__.items():
            if callable(v) and v.__doc__ and v.__name__ == command :
                help = v.__doc__.strip()
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 _syncdown_remote_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _syncdown_remote_one(self, rpath, localdir, r):
        result = const.ENoError
        t = r[0]
        p = r[1]
        #lcpath = os.path.join(localdir, p) # local complete path
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def format(self, obj, context, maxlevels, level):
        if isinstance(obj, unicode):
            #return (obj.encode('utf8'), True, False)
            return (obj, True, False)
        if isinstance(obj, bytes):
Severity: Minor
Found in bypy/util.py - About 25 mins to fix

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 stringifypickle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def stringifypickle(picklecache):
    for absdir in picklecache:
        entry = picklecache[absdir]
        for file in entry:
            info = entry[file]
Severity: Minor
Found in bypy/cached.py - About 25 mins to fix

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 _syncup_single has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _syncup_single(self, localdir, rpath, compare_result):
        result = const.ENoError
        same, diff, local, remote = compare_result
        # clear the way
        for d in diff:
Severity: Minor
Found in bypy/bypy.py - About 25 mins to fix

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 allpath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def allpath(self):
        result = []

        for k, v in self.items():
            result.append(k)
Severity: Minor
Found in bypy/struct.py - About 25 mins to fix

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 print_pcs_list_bare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def print_pcs_list_bare(list):
    if list:
        for f in list:
            pr("{} {} {} {} {} {}".format(
                ls_type(f['isdir']),
Severity: Minor
Found in bypy/util.py - About 25 mins to fix

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

Severity
Category
Status
Source
Language