Exemplo n.º 1
0
def valid_set_method_bool(method_invocation, str_bool, method_name="setAllowFileAccess"):
    """
    Determines if the `method_invocation` has the same `method_name` and has an argument of value `str_bool`

    :param MethodInvocation method_invocation: The javalang MethodInvocation
    :param str str_bool: The value of what should be in the argument
    :param str method_name: The name of the method to be found
    :return: Whether the MethodInvocation matches the method name and has the `str_bool` value as its first argument.
    :rtype: bool
    """
    return (valid_method_invocation(method_invocation, method_name, num_arguments=1)
            and method_invocation.arguments[0].value == str_bool)
Exemplo n.º 2
0
 def run_coroutine(self):
     while True:
         _, method_invocation = (yield)
         if valid_method_invocation(method_invocation,
                                    method_name=self.java_method_name,
                                    num_arguments=2):
             self.issues.append(
                 Issue(category=self.category,
                       name=self.name,
                       severity=self.severity,
                       description=self.description,
                       line_number=method_invocation.position,
                       file_object=self.file_path))
Exemplo n.º 3
0
 def run(self):
     if self.min_sdk <= 16:
         for _, method_invocation in self.java_ast.filter(MethodInvocation):
             if valid_method_invocation(method_invocation,
                                        method_name=self.java_method_name,
                                        num_arguments=2):
                 self.issues.append(
                     Issue(category=self.category,
                           name=self.name,
                           severity=self.severity,
                           description=self.description,
                           line_number=method_invocation.position,
                           file_object=self.file_path))