<commit_before>package com.siyeh.ipp.junit;

import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.openapi.project.Project;
import com.siyeh.ipp.base.PsiElementPredicate;

class CreateAssertPredicate implements PsiElementPredicate{
    CreateAssertPredicate(){
        super();
    }

    public boolean satisfiedBy(PsiElement element){
        if(!(element instanceof PsiExpressionStatement)){
            return false;
        }

        final PsiExpressionStatement statement =
                (PsiExpressionStatement) element;
        final PsiExpression expression = statement.getExpression();
        final PsiElement parent = expression.getParent();
        if(!(parent instanceof PsiExpressionStatement))
        {
            return false;
        }
        final PsiType type = expression.getType();
        if(!PsiType.BOOLEAN.equals(type))
        {
            return false;
        }
        final PsiClass containingClass =
                (PsiClass) PsiTreeUtil.getParentOfType(expression, PsiClass.class);
        if(!isTest(containingClass))
        {
            return false;
        }

        final PsiMethod containingMethod =
                (PsiMethod) PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
        return isTestMethod(containingMethod);

    }

    private boolean isTestMethod(PsiMethod method){
        if(method.hasModifierProperty(PsiModifier.ABSTRACT) ||
                   !method.hasModifierProperty(PsiModifier.PUBLIC)){
            return false;
        }

        final PsiType returnType = method.getReturnType();
        if(returnType == null){
            return false;
        }
        if(!returnType.equals(PsiType.VOID)){
            return false;
        }
        final PsiParameterList parameterList = method.getParameterList();
        if(parameterList == null){
            return false;
        }
        final PsiParameter[] parameters = parameterList.getParameters();
        if(parameters == null){
            return false;
        }
        if(parameters.length != 0){
            return false;
        }
        final String methodName = method.getName();
        return methodName.startsWith("test");
    }

    public static boolean isTest(PsiClass aClass){
        final PsiManager psiManager = aClass.getManager();
        final Project project = psiManager.getProject();
        final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
        final PsiClass ancestorClass =
                psiManager.findClass("junit.framework.TestCase", scope);
        return InheritanceUtil.isInheritorOrSelf(aClass, ancestorClass, true);
    }

}<commit_msg>(no message)<commit_after>package com.siyeh.ipp.junit;

import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.openapi.project.Project;
import com.siyeh.ipp.base.PsiElementPredicate;

class CreateAssertPredicate implements PsiElementPredicate{
    CreateAssertPredicate(){
        super();
    }

    public boolean satisfiedBy(PsiElement element){
        if(!(element instanceof PsiExpressionStatement)){
            return false;
        }

        final PsiExpressionStatement statement =
                (PsiExpressionStatement) element;
        final PsiExpression expression = statement.getExpression();
        final PsiElement parent = expression.getParent();
        if(!(parent instanceof PsiExpressionStatement))
        {
            return false;
        }
        final PsiType type = expression.getType();
        if(!PsiType.BOOLEAN.equals(type))
        {
            return false;
        }
        final PsiClass containingClass =
                (PsiClass) PsiTreeUtil.getParentOfType(expression, PsiClass.class);
        if(!isTest(containingClass))
        {
            return false;
        }

        final PsiMethod containingMethod =
                (PsiMethod) PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
        return isTestMethod(containingMethod);

    }

    private boolean isTestMethod(PsiMethod method){
        if(method == null)
        {
            return false;
        }
        if(method.hasModifierProperty(PsiModifier.ABSTRACT) ||
                   !method.hasModifierProperty(PsiModifier.PUBLIC)){
            return false;
        }

        final PsiType returnType = method.getReturnType();
        if(returnType == null){
            return false;
        }
        if(!returnType.equals(PsiType.VOID)){
            return false;
        }
        final PsiParameterList parameterList = method.getParameterList();
        if(parameterList == null){
            return false;
        }
        final PsiParameter[] parameters = parameterList.getParameters();
        if(parameters == null){
            return false;
        }
        if(parameters.length != 0){
            return false;
        }
        final String methodName = method.getName();
        return methodName.startsWith("test");
    }

    public static boolean isTest(PsiClass aClass){
        if(aClass == null)
        {
            return false;
        }
        final PsiManager psiManager = aClass.getManager();
        final Project project = psiManager.getProject();
        final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
        final PsiClass ancestorClass =
                psiManager.findClass("junit.framework.TestCase", scope);
        return InheritanceUtil.isInheritorOrSelf(aClass, ancestorClass, true);
    }

}
{'fraction_non_alphanumeric': 0.08935795954265612, 'fraction_numerical': 0.00035180299032541777, 'mean_word_length': 2.348645465253239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629749', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1459, 'n_words': 293}