kevin1911 commited on
Commit
8790563
·
verified ·
1 Parent(s): 575eba3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -18
app.py CHANGED
@@ -68,7 +68,31 @@ def fetch_repo(github_url, token=None):
68
  except Exception as e:
69
  return f"Error: {str(e)}"
70
 
71
- # Function to analyze the repository
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  def analyze_code(github_url, token=None):
73
  try:
74
  repo_path = fetch_repo(github_url, token)
@@ -87,21 +111,5 @@ def analyze_code(github_url, token=None):
87
 
88
  return results
89
  except Exception as e:
90
- return f"Error: {str(e)}"
91
-
92
- # Create Gradio Interface
93
- def gradio_interface():
94
- def fetch_and_analyze(token):
95
- repos = authenticate_github(token)
96
- return repos
97
-
98
- gr.Interface(
99
- fn=fetch_and_analyze,
100
- inputs=[gr.Textbox(label="GitHub Token", type="password")],
101
- outputs="text",
102
- live=True,
103
- title="GitHub Repository Selector",
104
- description="Enter your GitHub token to fetch and analyze your repositories."
105
- ).launch(share=True)
106
 
107
- gradio_interface()
 
68
  except Exception as e:
69
  return f"Error: {str(e)}"
70
 
71
+ # Function to calculate cyclomatic complexity using Radon
72
+ def analyze_complexity(repo_path):
73
+ result = subprocess.run(['radon', 'cc', repo_path, '--json'], stdout=subprocess.PIPE)
74
+ complexity_data = result.stdout.decode('utf-8')
75
+ return complexity_data
76
+
77
+ # Function to run pylint for linting
78
+ def analyze_linting(repo_path):
79
+ pylint_output = []
80
+ pylint_runner = pylint.lint.Run([repo_path], reporter=TextReporter(pylint_output))
81
+ return "\n".join(pylint_output)
82
+
83
+ # Function to check test coverage
84
+ def analyze_coverage(repo_path):
85
+ result = subprocess.run(['pytest', '--cov', repo_path], stdout=subprocess.PIPE)
86
+ coverage_data = result.stdout.decode('utf-8')
87
+ return coverage_data
88
+
89
+ # Function to check for code duplication with jscpd
90
+ def analyze_duplication(repo_path):
91
+ result = subprocess.run(['jscpd', repo_path, '--reporters', 'text'], stdout=subprocess.PIPE)
92
+ duplication_data = result.stdout.decode('utf-8')
93
+ return duplication_data
94
+
95
+ # Main function to analyze the repository
96
  def analyze_code(github_url, token=None):
97
  try:
98
  repo_path = fetch_repo(github_url, token)
 
111
 
112
  return results
113
  except Exception as e:
114
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115