Few bugs and added codereport script and report

Rafael
jaume-nualart 7 months ago
parent f26c07dc3a
commit a60ba83221
  1. 2
      README.md
  2. 92
      web-html/TraHus-Code_report.txt
  3. 101
      web-html/codereport.py
  4. 15
      web-html/js/dash.js

@ -143,7 +143,7 @@ Every time we call save, it is a new board.
{
Name [String],
Description [String],
Parallel: [
col-left: [
{
order [int],
id [String],

@ -0,0 +1,92 @@
Total Report:
---
All Files: js/dash.js, ../py/import.py, ../py/main.py, dash.html, home.html, css/dash.css, config/config.js, config/datamap.js, ../py/README.md
Number of Lines: 3563
Number of Variables: 182
Number of Functions: 35
Number of If Statements: 14
Number of Switch Statements: 6
Number of ForEach Statements: 12
---
File: js/dash.js
Number of Lines: 1516
Number of Variables: 174
Number of Functions: 21
Number of If Statements: 14
Number of Switch Statements: 6
Number of ForEach Statements: 11
---
File: ../py/import.py
Number of Lines: 101
Number of Variables: 12
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: ../py/main.py
Number of Lines: 469
Number of Variables: 15
Number of Functions: 14
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: dash.html
Number of Lines: 1073
Number of Variables: 11
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: home.html
Number of Lines: 89
Number of Variables: 8
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 1
---
File: css/dash.css
Number of Lines: 103
Number of Variables: 0
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: config/config.js
Number of Lines: 12
Number of Variables: 5
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: config/datamap.js
Number of Lines: 80
Number of Variables: 3
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---
File: ../py/README.md
Number of Lines: 120
Number of Variables: 0
Number of Functions: 0
Number of If Statements: 0
Number of Switch Statements: 0
Number of ForEach Statements: 0
---

@ -0,0 +1,101 @@
import sys
import re
def analyze_file(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
num_lines = len(lines)
variables = []
functions = 0
ifs = 0
switches = 0
foreachs = 0
for line in lines:
line = line.strip()
# Check for variable declarations and add them to the list
var_declaration_match_js = re.match(r"^(var|let|const)\s+([\w$]+)", line)
var_declaration_match_py = re.match(r"^(?:.*)?(\w+)\s*=", line)
if var_declaration_match_js:
variable = var_declaration_match_js.group(2)
variables.append(variable)
elif var_declaration_match_py:
variable = var_declaration_match_py.group(1)
variables.append(variable)
# Count the number of function declarations
function_declaration_match_js = re.match(r"^(function)\s+[\w$]+\(", line)
function_declaration_match_py = re.match(r"^(?:def)\s+(?:(?:\w+\s*\(.*\))|(?:\w+))", line)
if function_declaration_match_js or function_declaration_match_py:
functions += 1
# Count the number of if statements
if re.match(r"^(if)\s*\(", line):
ifs += 1
# Count the number of switch statements
if re.match(r"^(switch)\s*\(", line):
switches += 1
# Count the number of forEach statements
if re.match(r"^(.+)\.forEach\s*\(", line):
foreachs += 1
return {
'file': file_path,
'num_lines': num_lines,
'num_variables': variables,
'num_functions': functions,
'num_ifs': ifs,
'num_switches': switches,
'num_foreachs': foreachs
}
if __name__ == '__main__':
if len(sys.argv) < 2:
print('Please provide at least one JavaScript or Python file to analyze.')
sys.exit(1)
total_lines = 0
total_variables = []
total_functions = 0
total_ifs = 0
total_switches = 0
total_foreachs = 0
reports = []
for file_path in sys.argv[1:]:
analysis = analyze_file(file_path)
total_lines += analysis["num_lines"]
total_variables.extend(analysis["num_variables"])
total_functions += analysis["num_functions"]
total_ifs += analysis["num_ifs"]
total_switches += analysis["num_switches"]
total_foreachs += analysis["num_foreachs"]
report = f'File: {analysis["file"]}\n'
report += f'Number of Lines: {analysis["num_lines"]}\n'
report += f'Number of Variables: {len(set(analysis["num_variables"]))}\n'
report += f'Number of Functions: {analysis["num_functions"]}\n'
report += f'Number of If Statements: {analysis["num_ifs"]}\n'
report += f'Number of Switch Statements: {analysis["num_switches"]}\n'
report += f'Number of ForEach Statements: {analysis["num_foreachs"]}\n'
report += '---\n'
reports.append(report)
print('Total Report:')
print('---')
print(f'All Files: {", ".join(sys.argv[1:])}')
print(f'Number of Lines: {total_lines}')
print(f'Number of Variables: {len(set(total_variables))}')
print(f'Number of Functions: {total_functions}')
print(f'Number of If Statements: {total_ifs}')
print(f'Number of Switch Statements: {total_switches}')
print(f'Number of ForEach Statements: {total_foreachs}')
print('---\n')
for report in reports:
print(report)

@ -546,12 +546,13 @@ function do_parallel(myid, myxs, mycolumns, inMyTitle) {
// optional: , position: 'middle', 'start'
]
}
},
regions: [
{axis: 'x', start: 5, end: 10},
{axis: 'x', start: 25, end: 35},
{axis: 'x', start: 42, end: 45} ////, class: 'regionY'} // start => 2014-01-25 00:00:00, end => 2014-01-30 00:00:00
]
}
// ,
// regions: [
// {axis: 'x', start: 5, end: 10},
// {axis: 'x', start: 25, end: 35},
// {axis: 'x', start: 42, end: 45} ////, class: 'regionY'} // start => 2014-01-25 00:00:00, end => 2014-01-30 00:00:00
// ]
});
myButtons =`
<span class="corner-close" onclick="removeDiv(this)"><i class="fa fa-close"></i></span>
@ -1120,7 +1121,7 @@ document.querySelectorAll('button[type="submit"]').forEach(button => {
// Get the form data based on the form ID
const formData = getFormData(formId);
// Display or use the form data
console.log(`Form Data for ${formId}:`, formData);
//cl(`Form Data for ${formId}:`, formData);
// Is it a diagram or a text?
if (formId.substring(1)=="Text") {
var fromEditor = document.getElementById(formId[0]+"editor").innerHTML;

Loading…
Cancel
Save