예제 #1
0
def main() -> None:
    args = _init_argparse().parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    design = load_design(args.design, generate_example=True)

    full_hierarchy = build_hierarchy(_input_parsers[args.parser](args.index),
                                     design.layers)

    hierarchy = Hierarchy()
    for f in args.filters:
        hierarchy = filter_hierarchy(full_hierarchy, f, hierarchy)

        for cls in hierarchy.classes:
            for d in cls.dependencies:
                if d.is_production:
                    _add_to(
                        full_hierarchy[d.layer][d.module][d.package][d.name],
                        hierarchy)

    find_smells(hierarchy, design.smells)

    timestamp = time.strftime("%Y%m%d-%H-%M", time.localtime())
    for format_key in args.outputs:
        _output_formats[format_key](os.path.join("report-" + timestamp,
                                                 format_key), hierarchy)
예제 #2
0
def test_load_default_design_if_file_not_exist(tmp_path):
    design = load_design(tmp_path / "design.ini")
    assert [type(s).__name__ for s in design.smells] == [
        'SmellDependencyCrossModule', 'SmellDependencyCrossPackage',
        'SmellCylicDependency'
    ]
    assert design.layers == {}
    assert not os.path.exists(tmp_path / "design.ini")
예제 #3
0
def test_generate_sample_design_if_file_not_exist(tmp_path):
    assert not os.path.exists(tmp_path / "design.ini")
    design = load_design(tmp_path / "design.ini", generate_example=True)
    assert os.path.exists(tmp_path / "design.ini")
    assert [type(s).__name__ for s in design.smells] == [
        'SmellDependencyCrossModule', 'SmellDependencyCrossPackage',
        'SmellCylicDependency'
    ]
    assert design.layers == {}
예제 #4
0
def main() -> None:
    design = load_design("design.ini")

    full_hierarchy = build_hierarchy(input_idea.read_file("index.xml"),
                                     design.layers)
    hierarchy = filter_hierarchy(full_hierarchy,
                                 "unknown:app:com.fastaccess:A*", Hierarchy())

    find_smells(hierarchy, design.smells)

    dt = time.strftime("report-%Y%m%d-%H-%M", time.localtime())
    output_md.write_files(os.path.join(dt, 'md'), hierarchy)
    output_uml.write_files(os.path.join(dt, 'uml'), hierarchy)
예제 #5
0
def test_load_design(tmp_path):
    with open(tmp_path / "design.ini", 'w', encoding='utf-8') as design_file:
        design_file.write(sample_design)

    design = load_design(tmp_path / "design.ini")
    assert [type(s).__name__ for s in design.smells] == [
        'SmellDependencyCrossModule', 'SmellDependencyCrossPackage',
        'SmellCylicDependency', 'SmellDependency', 'SmellDependency',
        'SmellDependency'
    ]
    assert design.layers == {
        'platform': [{
            'module': 'app',
            'package': 'com.pretty.helper'
        }, {
            "path": ":app:com.pretty.util"
        }]
    }