Skip to content

Defects uncovered while bringing test coverage for JCodeAnalyzer, JavaAnalysis, and JavaSitter up to 90% #74

@rofrano

Description

@rofrano

Description

The following defects were found while implementing test cases for JCodeAnalyzer, JavaAnalysis, and JavaSitter. It look like several of them have a common cause so I didn't feel they needed separate bug reports. I created checkboxes for the issues so that you can keep track of them as you fix them.

Note: You need to accept this Pull Request in order to see the test cases: Created test cases to bring JCodeAnalyzer, JavaAnalysis, and JavaSitter to 90% test coverage #75

JCodeAnalyzer issues

  • Calling JCodeanalyzer.get_all_callers() with the parameter using_symbol_table=True returns:
$ pytest -x tests/analysis/java/test_jcodeanalyzer.py -k test_get_all_callers

FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the callers - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JCodeanalyzer.get_all_callees() with the parameter using_symbol_table=True returns:
$ pytest -x tests/analysis/java/test_jcodeanalyzer.py -k test_get_all_callees

FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the callees - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JCodeanalyzer.get_class_call_graph_using_symbol_table() for a class like "com.ibm.websphere.samples.daytrader.impl.direct.AsyncOrder" with the method "run()" returns the following error:
$ pytest -x tests/analysis/java/test_jcodeanalyzer.py -k test_get_class_call_graph_using_symbol_table

FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return the call graph using the symbol table - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JCodeanalyzer.get_all_nested_classes() for a class like com.ibm.websphere.samples.daytrader.util.KeyBlock that has 1 nested class fails with:
$ pytest -x tests/analysis/java/test_jcodeanalyzer.py -k test_get_all_nested_classes

FAILED tests/analysis/java/test_jcodeanalyzer.py::::It should return all of the nested classes for a class - assert 0 == 1

JavaAnalysis issues

  • Calling JavaAnalysis.get_callers() on "com.ibm.websphere.samples.daytrader.util.Log.log(String)" with parameter using_symbol_table=True returns the following error:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_callers

FAILED tests/analysis/java/test_java_analysis.py::::It should return the callers - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JavaAnalysis.get_nested_classes() on "com.ibm.websphere.samples.daytrader.web.websocket.ActionMessage.doDecoding(String)" with parameter using_symbol_table=True returns the following error:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_callees

FAILED tests/analysis/java/test_java_analysis.py::::It should return the callees - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JavaAnalysis.get_callers() for a class like com.ibm.websphere.samples.daytrader.util.KeyBlock that has 1 nested class fails with:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_nested_classes

FAILED tests/analysis/java/test_java_analysis.py::::It should return the nested classes for a class - assert 0 == 1
  • Calling JavaAnalysis.get_class_call_graph() with using_symbol_table=True returns the following error:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_class_call_graph

FAILED tests/analysis/java/test_java_analysis.py::::It should return the class call graph - TypeError: JavaSitter.get_calling_lines() missing 1 required positional argument: 'is_target_method_a_constructor'
  • Calling JavaAnalysis.test_remove_all_comments() is in conflict. It requires Treesitter but the JCodeanalyzer does not implement it:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_remove_all_comments

FAILED tests/analysis/java/test_java_analysis.py::::It should remove all comments - NotImplementedError: Support for this functionality has not been implemented yet.
  • Calling JavaAnalysis.get_methods_with_annotations() is in conflict. It requires Treesitter but the JCodeanalyzer does not implement it:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_methods_with_annotations

FAILED tests/analysis/java/test_java_analysis.py::::It should return methods with annotations - NotImplementedError: Support for this functionality has not been implemented yet.
  • Calling JavaAnalysis.get_test_methods() is in conflict. It requires Treesitter but the JCodeanalyzer does not implement it:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_test_methods

FAILED tests/analysis/java/test_java_analysis.py::::It should return test methods - NotImplementedError: Support for this functionality has not been implemented yet.
  • Calling JavaAnalysis.get_calling_lines() is calling a method get_calling_lines on JCodeAnalyzer that doesn't exists and returns the following error:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_calling_lines

FAILED tests/analysis/java/test_java_analysis.py::::It should return calling lines - AttributeError: 'JCodeanalyzer' object has no attribute 'get_calling_lines'
  • Calling JavaAnalysis.get_call_targets() is calling a method get_call_targets on JCodeAnalyzer that doesn't exists and returns the following error:
$ pytest -x tests/analysis/java/test_java_analysis.py -k test_get_call_targets

FAILED tests/analysis/java/test_java_analysis.py::::It should return calling targets - AttributeError: 'JCodeanalyzer' object has no attribute 'get_call_targets'

JavaSitter issues

  • Calling JavaSitter.get_superclass() passing in the source code for com.ibm.websphere.samples.daytrader.util.KeyBlock returns the following error instead of AbstractSequentialList:
$ pytest -x tests/analysis/java/test_java_sitter.py -k test_get_superclass

FAILED tests/analysis/java/test_java_sitter.py::::It should return the superclass name - AssertionError: assert '' == 'AbstractSequentialList'
  • Calling JavaSitter.safe_ascend() passing in a child node and an ascend_count of 1 returns a ValueError. Shouldn't it return the parent of the child? I believe the logic should test for ascend_count == 0 before it tests for node.parent is None:
$ pytest -x tests/analysis/java/test_java_sitter.py -k test_safe_ascend

FAILED tests/analysis/java/test_java_sitter.py::::It should safely ascend a node - ValueError: Node has no parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions