Skip to content

Commit 4ff354f

Browse files
authored
Merge pull request #111 from codellm-devkit/104-tests-are-failing-upon-migration-to-codeanalyzer-21
Fix Issue 104: Tests are failing upon migration to `codeanalyzer` v2.1.0+
2 parents 77618eb + 15d6a32 commit 4ff354f

File tree

147 files changed

+23960
-22530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+23960
-22530
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ lint: ## Run the linter
3131
.PHONY: test
3232
test: ## Run the unit tests
3333
$(info Running tests...)
34-
pytest --pspec --cov=cldk --cov-fail-under=50 --disable-warnings
34+
pytest --pspec --cov=cldk --cov-fail-under=70 --disable-warnings
3535

3636
##@ Build
3737

Diff for: cldk/analysis/c/c_analysis.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
from pathlib import Path
2222
from typing import Dict, List, Optional
23+
import networkx as nx
2324

24-
from networkx import DiGraph
2525

2626
from cldk.analysis.c.clang import ClangAnalyzer
2727
from cldk.models.c import CApplication, CFunction, CTranslationUnit, CMacro, CTypedef, CStruct, CEnum, CVariable
@@ -56,7 +56,7 @@ def _init_application(self, project_dir: Path) -> CApplication:
5656
return CApplication(translation_units=translation_units)
5757

5858
def get_c_application(self) -> CApplication:
59-
"""Returns the C application object.
59+
"""returns the C application object.
6060
6161
Returns:
6262
CApplication: C application object.
@@ -89,16 +89,16 @@ def is_parsable(self, source_code: str) -> bool:
8989
"""
9090
raise NotImplementedError("Support for this functionality has not been implemented yet.")
9191

92-
def get_call_graph(self) -> DiGraph:
93-
"""Returns the call graph of the C code.
92+
def get_call_graph(self) -> nx.DiGraph:
93+
"""returns the call graph of the C code.
9494
9595
Returns:
96-
DiGraph: The call graph of the C code.
96+
nx.DiGraph: The call graph of the C code.
9797
"""
9898
raise NotImplementedError("Support for this functionality has not been implemented yet.")
9999

100100
def get_call_graph_json(self) -> str:
101-
"""Returns a serialized call graph in json.
101+
"""returns a serialized call graph in json.
102102
103103
Raises:
104104
NotImplementedError: Raised when this functionality is not suported.
@@ -110,7 +110,7 @@ def get_call_graph_json(self) -> str:
110110
raise NotImplementedError("Producing a call graph over a single file is not implemented yet.")
111111

112112
def get_callers(self, function: CFunction) -> Dict:
113-
"""Returns a dictionary of callers of the target method.
113+
"""returns a dictionary of callers of the target method.
114114
115115
Args:
116116
function (CFunction): A CFunction object.
@@ -125,7 +125,7 @@ def get_callers(self, function: CFunction) -> Dict:
125125
raise NotImplementedError("Generating all callers over a single file is not implemented yet.")
126126

127127
def get_callees(self, function: CFunction) -> Dict:
128-
"""Returns a dictionary of callees in a fuction.
128+
"""returns a dictionary of callees in a fuction.
129129
130130
Args:
131131
function (CFunction): A CFunction object.
@@ -139,7 +139,7 @@ def get_callees(self, function: CFunction) -> Dict:
139139
raise NotImplementedError("Generating all callees over a single file is not implemented yet.")
140140

141141
def get_functions(self) -> Dict[str, CFunction]:
142-
"""Returns all functions in the project.
142+
"""returns all functions in the project.
143143
144144
Raises:
145145
NotImplementedError: Raised when current AnalysisEngine does not support this function.
@@ -151,7 +151,7 @@ def get_functions(self) -> Dict[str, CFunction]:
151151
return translation_unit.functions
152152

153153
def get_function(self, function_name: str, file_name: Optional[str]) -> CFunction | List[CFunction]:
154-
"""Returns a function object given the function name.
154+
"""returns a function object given the function name.
155155
156156
Args:
157157
function_name (str): The name of the function.
@@ -163,7 +163,7 @@ def get_function(self, function_name: str, file_name: Optional[str]) -> CFunctio
163163
raise NotImplementedError("Support for this functionality has not been implemented yet.")
164164

165165
def get_C_file(self, file_name: str) -> str:
166-
"""Returns a class given qualified class name.
166+
"""returns a class given qualified class name.
167167
168168
Args:
169169
file_name (str): The name of the file.
@@ -191,7 +191,7 @@ def get_C_compilation_unit(self, file_path: str) -> CTranslationUnit:
191191
return self.c_application.translation_units.get(file_path)
192192

193193
def get_functions_in_file(self, file_name: str) -> List[CFunction]:
194-
"""Returns a dictionary of all methods of the given class.
194+
"""returns a dictionary of all methods of the given class.
195195
196196
Args:
197197
file_name (str): The name of the file.
@@ -205,7 +205,7 @@ def get_functions_in_file(self, file_name: str) -> List[CFunction]:
205205
raise NotImplementedError("Support for this functionality has not been implemented yet.")
206206

207207
def get_macros(self) -> List[CMacro]:
208-
"""Returns a list of all macros in the C code.
208+
"""returns a list of all macros in the C code.
209209
210210
Raises:
211211
NotImplementedError: Raised when current AnalysisEngine does not support this function.
@@ -216,7 +216,7 @@ def get_macros(self) -> List[CMacro]:
216216
raise NotImplementedError("Support for this functionality has not been implemented yet.")
217217

218218
def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
219-
"""Returns a list of all macros in the given file.
219+
"""returns a list of all macros in the given file.
220220
221221
Args:
222222
file_name (str): The name of the file.
@@ -231,7 +231,7 @@ def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
231231

232232

233233
def get_includes(self) -> List[str]:
234-
"""Returns a list of all include statements across all files in the C code.
234+
"""returns a list of all include statements across all files in the C code.
235235
236236
Returns:
237237
List[str]: A list of all include statements. Returns empty list if none found.
@@ -243,7 +243,7 @@ def get_includes(self) -> List[str]:
243243

244244

245245
def get_includes_in_file(self, file_name: str) -> List[str] | None:
246-
"""Returns a list of all include statements in the given file.
246+
"""returns a list of all include statements in the given file.
247247
248248
Args:
249249
file_name (str): The name of the file to search in.
@@ -257,7 +257,7 @@ def get_includes_in_file(self, file_name: str) -> List[str] | None:
257257

258258

259259
def get_macros(self) -> List[CMacro]:
260-
"""Returns a list of all macro definitions across all files in the C code.
260+
"""returns a list of all macro definitions across all files in the C code.
261261
262262
Returns:
263263
List[CMacro]: A list of all macro definitions. Returns empty list if none found.
@@ -269,7 +269,7 @@ def get_macros(self) -> List[CMacro]:
269269

270270

271271
def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
272-
"""Returns a list of all macro definitions in the given file.
272+
"""returns a list of all macro definitions in the given file.
273273
274274
Args:
275275
file_name (str): The name of the file to search in.
@@ -283,7 +283,7 @@ def get_macros_in_file(self, file_name: str) -> List[CMacro] | None:
283283

284284

285285
def get_typedefs(self) -> List[CTypedef]:
286-
"""Returns a list of all typedef declarations across all files in the C code.
286+
"""returns a list of all typedef declarations across all files in the C code.
287287
288288
Returns:
289289
List[CTypedef]: A list of all typedef declarations. Returns empty list if none found.
@@ -295,7 +295,7 @@ def get_typedefs(self) -> List[CTypedef]:
295295

296296

297297
def get_typedefs_in_file(self, file_name: str) -> List[CTypedef] | None:
298-
"""Returns a list of all typedef declarations in the given file.
298+
"""returns a list of all typedef declarations in the given file.
299299
300300
Args:
301301
file_name (str): The name of the file to search in.
@@ -309,7 +309,7 @@ def get_typedefs_in_file(self, file_name: str) -> List[CTypedef] | None:
309309

310310

311311
def get_structs(self) -> List[CStruct]:
312-
"""Returns a list of all struct/union declarations across all files in the C code.
312+
"""returns a list of all struct/union declarations across all files in the C code.
313313
314314
Returns:
315315
List[CStruct]: A list of all struct/union declarations. Returns empty list if none found.
@@ -321,7 +321,7 @@ def get_structs(self) -> List[CStruct]:
321321

322322

323323
def get_structs_in_file(self, file_name: str) -> List[CStruct] | None:
324-
"""Returns a list of all struct/union declarations in the given file.
324+
"""returns a list of all struct/union declarations in the given file.
325325
326326
Args:
327327
file_name (str): The name of the file to search in.
@@ -335,7 +335,7 @@ def get_structs_in_file(self, file_name: str) -> List[CStruct] | None:
335335

336336

337337
def get_enums(self) -> List[CEnum]:
338-
"""Returns a list of all enum declarations across all files in the C code.
338+
"""returns a list of all enum declarations across all files in the C code.
339339
340340
Returns:
341341
List[CEnum]: A list of all enum declarations. Returns empty list if none found.
@@ -347,7 +347,7 @@ def get_enums(self) -> List[CEnum]:
347347

348348

349349
def get_enums_in_file(self, file_name: str) -> List[CEnum] | None:
350-
"""Returns a list of all enum declarations in the given file.
350+
"""returns a list of all enum declarations in the given file.
351351
352352
Args:
353353
file_name (str): The name of the file to search in.
@@ -361,7 +361,7 @@ def get_enums_in_file(self, file_name: str) -> List[CEnum] | None:
361361

362362

363363
def get_globals(self, file_name: str) -> List[CVariable] | None:
364-
"""Returns a list of all global variable declarations in the given file.
364+
"""returns a list of all global variable declarations in the given file.
365365
366366
Args:
367367
file_name (str): The name of the file to search in.

0 commit comments

Comments
 (0)