-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 'master' See merge request persper/code-analytics!89
- Loading branch information
Showing
36 changed files
with
1,290 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
stages: | ||
- build | ||
- test | ||
|
||
|
||
test_ci: | ||
stage: test | ||
image: ubuntu:18.04 | ||
# only: | ||
# - setup-ci | ||
before_script: | ||
- apt update && apt install -y openssh-client wget libarchive-dev libcurl4-openssl-dev git python3.7 python3-pip | ||
- wget http://131.123.42.38/lmcrs/beta/srcML-Ubuntu18.04.deb | ||
- dpkg -i srcML-Ubuntu18.04.deb | ||
- mkdir -p ~/.ssh | ||
- echo "${DEPLOY_KEY}" | tr -d '\r' > ~/.ssh/id_rsa | ||
- chmod 600 ~/.ssh/id_rsa | ||
- eval "$(ssh-agent -s)" | ||
- ssh-keyscan -H "gitlab.com" >> ~/.ssh/known_hosts | ||
- chmod 644 ~/.ssh/known_hosts | ||
- set LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib | ||
- export LC_ALL=C.UTF-8 | ||
- export LANG=C.UTF-8 | ||
script: | ||
- apt-get update | ||
- git config --global user.email "[email protected]" | ||
- git config --global user.name "merico" | ||
- pip3 install pipenv | ||
|
||
- echo -e "machine gitlab.com\nlogin ${GITLAB_USER}\npassword ${GITLAB_PASSWD}" > ~/.netrc | ||
- git clone https://gitlab.com/persper/code-analytics.git && cd code-analytics | ||
#&& git checkout ${CI_COMMIT_REF_NAME} | ||
- export PYTHONPATH=$PYTHONPATH:/root/code-analytics | ||
- pipenv install --python 3.7 | ||
- pipenv run pytest -s test/test_analytics | ||
- pipenv run pytest -s test/test_analytics2 | ||
- echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
from typing import Dict, List | ||
|
||
import numpy as np | ||
from networkx import DiGraph | ||
|
||
_logger = logging.getLogger(__file__) | ||
|
||
|
||
def eval_project_complexity(G: DiGraph, r_n: float, r_e: float): | ||
""" | ||
Evaluates project complexity from the specified bare call commit graph. | ||
remarks | ||
The formula is | ||
complexity = sum_by_node(added_units + removed_units) + r_n*len(nodes) + r_e*len(edges) | ||
""" | ||
logical_units = 0 | ||
useFallback = None | ||
for _, data in G.nodes(data=True): | ||
added = 0 | ||
removed = 0 | ||
for _, v in data["history"].items(): | ||
if useFallback == None: | ||
useFallback = not "added_units" in v | ||
if useFallback: | ||
_logger.warning( | ||
"Will use LOC instead of logic units to measure complexity.") | ||
if useFallback: | ||
added += v["adds"] | ||
removed += v["dels"] | ||
else: | ||
added += v["added_units"] | ||
removed += v["removed_units"] | ||
logical_units += added + removed | ||
complexity = logical_units + r_n*len(G.nodes) + r_e*len(G.edges) | ||
return complexity |
Oops, something went wrong.