Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HIS): add STMT his metric #74

Open
wants to merge 1 commit into
base: wip/his-metrics
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ RUN apt-get update && apt-get install -y \
tree \
vim \
nano \
device-tree-compiler
device-tree-compiler \
npm

# Install python packages
RUN pip3 install \
Expand Down
37 changes: 34 additions & 3 deletions his_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import sys
import argparse
import os

def process_calling(files, threshold):
"""
Expand Down Expand Up @@ -85,12 +86,42 @@ def process_return(files, threshold):

def process_stmt(files, threshold):
"""
Process the stmt metric
Process number of statements in each function. This function checks each function in the
provided files for their number of statements. If the number of statements in a function
exceeds the defined threshold, an error message is printed and the error count is incremented.

Args:
files: A list of file paths to check for statements.
threshold: The maximum number statements allowed in a function.

Returns:
The number of files that exceed the statements threshold.
"""

print(f"Processing STMT metric with threshold [1-{threshold}] for files: {', '.join(files)}")
metric_fail = 0
pmccabe_stat_index = 2
function_index = 5
statements_tool = "pmccabe -c "

return 0
print("--------------------------------------------")
print(f"Processing STMT metric with threshold [1-{threshold}]")
print("--------------------------------------------")

# Process each file
for file in files:
# Run 'pmccabe' on the file and split the output into lines
sline = os.popen(statements_tool + str(file)).read().split('\n')

for fields in [line.split('\t') for line in sline[:-1]]:
statements = int(fields[pmccabe_stat_index])

if statements > threshold:
func_name = fields[function_index].split()
print("At " + file + " function " + func_name[1] + " has a total of " +
str(statements) + " statements")
metric_fail += 1

return metric_fail

def process_vocf(files, threshold):
"""
Expand Down