Commit a747b8f9 authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

Merge branch '46-feat-wily' into 'master'

Resolve "feat: wily"

Closes #46

See merge request ci/templates!17
parents 6bc673e0 1e53586f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ include:
  - local: 'python/mypy.yml'
  - local: 'python/pylint.yml'
  - local: 'python/safety.yml'
  - local: 'python/wily.yml'

  - local: 'c/cppcheck.yml'
  - local: 'c/flawfinder.yml'

python/wily.yml

0 → 100644
+48 −0
Original line number Diff line number Diff line
---
# https://wily.readthedocs.io/en/latest/
# this job uses `wily diff` to provide code quality/complexity metrics for python projects
# you can use it to evaluate progress while refactoring a project...
# or to evaluate complexity/maintainability changes introduced by a MR

.python:wily:
  stage: test
  image: registry.gitlab.com/notno/python-tests
  variables:
    CHECK_PATH: "./${PYTHON_PACKAGE}"
    EXTRA_PATHS: "" 
    EXTRA_ARGS: ""
    DEFAULT_OPTIONS: "-c --detail"
    EXTRA_OPTIONS: ""  # Add --all to show the metrics of all files
    DEFAULT_METRICS: "--metrics maintainability.rank,maintainability.mi,halstead.effort,cyclomatic.complexity,raw.loc,raw.single_comments"
    EXTRA_METRICS: ""  # Start with a comma, and leave no comma between metrics
    GIT_STRATEGY: clone
    GIT_CHECKOUT: "false"
  script:
    - echo "Preparing environment"
    - git fetch 1>/dev/null 2>&1
    - git checkout ${CI_COMMIT_REF_NAME} 1>/dev/null 2>&1
    - wily build ${CHECK_PATH} 1>/dev/null 2>&1
    - |
      wily ${EXTRA_ARGS} diff ${DEFAULT_OPTIONS} ${EXTRA_OPTIONS} ${CHECK_PATH} ${EXTRA_PATHS} -r HEAD^1 ${DEFAULT_METRICS}${EXTRA_METRICS} > wily_head-1_compared
      if [ -s wily_head-1_compared ]; then
        echo "Comparison between your current commit and the previous commit:"
        cat wily_head-1_compared
      else
        echo "No difference in metrics compared to the previous commit."
      fi
    - |
      wily ${EXTRA_ARGS} diff ${DEFAULT_OPTIONS} ${EXTRA_OPTIONS} ${CHECK_PATH} ${EXTRA_PATHS} -r origin/master ${DEFAULT_METRICS}${EXTRA_METRICS} > wily_master_compared
      if [ -s wily_master_compared ]; then
        echo "Comparison between your current commit and the master branch:"
        cat wily_master_compared
      else
        echo "No difference in metrics compared to master."
      fi
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - when: always
  needs: []

python:wily:
  extends: .python:wily
+7 −0
Original line number Diff line number Diff line
@@ -11,3 +11,10 @@ def myfunction(variable: int) -> int:
def myotherfunction(variable: int) -> int:
    """this function is even more useful"""
    return variable - 1


def too_complicated() -> None:
    """this function will increase code complexity"""
    for i in range(1000):
        print("was this really necessary??")
    print("I guess it was")
+43 −43

File changed.

Contains only whitespace changes.

+25 −25

File changed.

Contains only whitespace changes.