anubis package

Anubis

This is the root of the package Anubis, meant for preforming CodeMetrics Analyses on codebases.

Submodules

anubis.external_analysis module

External analysis for anubis

anubis.external_analysis.create_complexity_database(lizard_db: dict, blame_db: list, indent: int = 4)

Add CIndent infos from the blame data and clean the lizard_info

Parameters
  • lizard_db (dict) – dict contain the lizard outputs

  • blame_db (list) – list of dicts containing the blame infos

  • indent (int) – number of whitespaces defined as an indentation ( default is 4)

Returns

updated lizard_db cleaned and with new CIndent infos

Return type

dict

anubis.external_analysis.run_lizard(path, optional_path_list)

evaluate complexity with lizard Args :

path (str): main git source path to analyze optional_path_list (str): optional git source path to analyze

note ::

takes approx 5-7 sec on AVBP/SOURCES

anubis.git_helpers module

All the git helpers for anubis

anubis.git_helpers.git_blame(path: str, print_log=True) dict

git blame for each code file in given directory

Git blame is applied to code files only, determined by their extension or their name.

For each file, git_blame retrieves for each non blank code line the following information:
  • last author

  • last modification date

  • number of indentation (i.e. number of blank before first non blank character)

Parameters

path (str) – relative path to sources

Returns

contains git blame information for each code file in source directory

Return type

blame_info (dict)

anubis.git_helpers.git_branch_status(ref_commit: str, date: str, ref_branch: str) list

get branch status for each branch

Parameters
  • ref_commit (str) – reference commit (on reference branch)

  • date (str) – reference date for the branch status

  • ref_branch (str) – reference branch

Returns

contains branch status for each branch

Return type

branch_data (list)

anubis.git_helpers.git_checkout(revision)

git checkout by revision

anubis.git_helpers.git_last_revision(date, branch)

Get the last revision before a date

anubis.git_helpers.git_revision_stats(after_date, before_date, branch)

Get the last revision before a date

anubis.git_helpers.git_size(path: str, previous_size: float = 0.0)

get git repository size

This funtion relies on os.stat.st_size which gives the “size in bytes of a plain file; amount of data waiting on some special files”.

See official documentation of os.stats.st_size for more information about the size computation.

Parameters

path (str) – relative path to sources

Returns

size of the repository (bytes)

Return type

size (float)

anubis.git_helpers.git_tag_history(ref_branch: str) dict

get tag dates for a given branch

Parameters

ref_branch (str) – reference branch

Returns

dict of tag name and date

Return type

tags_date (dict)

anubis.git_helpers.parse_git_show_stats(show_lines, rev, br_type)

anubis.timemachine module

module able to spawn several temporal versions of a git codebase

anubis.timemachine.logging_start(f_log, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)

Initiate the logger

Parameters
  • f_log (str) – path of file to log

  • stream – stream where to redirect log

anubis.timemachine.main_timemachine(git_path, branch='master', rel_source_path='./', year_start=2020, year_end=2020, out_dir='ANUBIS_OUT', lizard_switch=True, optional_source_path_list=None)

Main call of timemachine

Args :

git_path (str): path to git repository branch (str): git branch to scan rel_source_path (str): path relative to git repo to limit the results year_start (int): starting year, included year_end (int): ending year, included out_dir (str): output directory lizard (bool): enable lizard evauation of complexity (can be long) optional_source_path_list (list(str)): list of optional source path to look at

anubis.timemachine.run(inputfile='./anubis_time_machine.yml')

Run anubis time machine from input file.

anubis.timemachine.timeloop(branch, path, year_start, year_end, out_dir, lizard_switch=True, optional_path_list=None)

Principal time loop for anubis.

Args :

branch (str): git branch to scan path (str): path relative to git repo to limit the results year_start (int): starting year, included year_end (int): ending year, included out_dir (str): output directory lizard (bool): enable lizard evauation of complexity (can be long) optional_path_list (list(str)): list of optional source path to look at