Passed
Pull Request — master (#110)
by Vinicius
23:49 queued 17:19
created

build.tests.unit.helpers   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 85.19 %

Importance

Changes 0
Metric Value
eloc 12
dl 23
loc 27
rs 10
c 0
b 0
f 0
wmc 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_napp_urls() 23 23 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
"""Module to help to create tests."""
2
3
4 View Code Duplication
def get_napp_urls(napp):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5
    """Return the kytos/topology urls.
6
7
    The urls will be like:
8
9
    urls = [
10
        (options, methods, url)
11
    ]
12
13
    """
14
    controller = napp.controller
15
    controller.api_server.register_napp_endpoints(napp)
16
17
    urls = []
18
    for rule in controller.api_server.app.url_map.iter_rules():
19
        options = {}
20
        for arg in rule.arguments:
21
            options[arg] = f"[{arg}]"
22
23
        if f'{napp.username}/{napp.name}' in str(rule):
24
            urls.append((options, rule.methods, f'{str(rule)}'))
25
26
    return urls
27