<commit_before>package com.iluwatar.domain;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DomainObject {

    private static final Logger log = LoggerFactory.getLogger(DomainObject.class);

    private static final List<String> IGNORED_METHODS = Arrays.asList("private static boolean[] $jacocoInit()");

    public final String packageName;
    public final String className;
    public final String description;
    public List<String> methods = new ArrayList<>();

    public DomainObject(String packageName, String className, String description) {
        this.packageName = packageName;
        this.className = className;
        this.description = description;
        Class<?> aClass = null;
        final String fqn = String.format("%s.%s", packageName, className);
        try {
            aClass = Class.forName(fqn);
            for (Method m: aClass.getDeclaredMethods()) {
                if (!IGNORED_METHODS.contains(formatMethodName(m))) {
                    methods.add(formatMethodName(m));
                }
            }
            methods.sort(String::compareTo);
        } catch (ClassNotFoundException e) {
            log.error("Could not get class for name {} Check that the plugin has declared the required dependencies!", fqn);
        }
    }

    public DomainObject(Class<?> clazz, String description) {
        this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
    }

    public DomainObject(Class<?> clazz) {
        this(clazz, null);
    }

    private String formatMethodName(Method method) {
        final String replaceOld = method.getReturnType().getName();
        final String replaceNew = method.getReturnType().getSimpleName();
        final String remove = String.format("%s.%s.", packageName, className);
        String s = method.toString().replace(remove, "").replace(replaceOld, replaceNew);
        for (Class clazz: method.getParameterTypes()) {
            if (clazz.isArray()) {
                String name = clazz.getName().replace("[L", "").replace(";", "").concat("[]");
                String replace = clazz.getSimpleName();
                s = s.replace(name, replace);
            } else {
                s = s.replace(clazz.getName(), clazz.getSimpleName());
            }
        }
        return s;
    }

    public String getPackageName() {
        return packageName;
    }<commit_msg>Don't report lambda methods<commit_after>package com.iluwatar.domain;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DomainObject {

    private static final Logger log = LoggerFactory.getLogger(DomainObject.class);

    private static final List<String> IGNORED_METHODS = Arrays.asList("private static boolean[] $jacocoInit()");

    public final String packageName;
    public final String className;
    public final String description;
    public List<String> methods = new ArrayList<>();

    public DomainObject(String packageName, String className, String description) {
        this.packageName = packageName;
        this.className = className;
        this.description = description;
        Class<?> aClass = null;
        final String fqn = String.format("%s.%s", packageName, className);
        try {
            aClass = Class.forName(fqn);
            for (Method m: aClass.getDeclaredMethods()) {
                if (!IGNORED_METHODS.contains(formatMethodName(m)) && !isLambda(formatMethodName(m))) {
                    methods.add(formatMethodName(m));
                }
            }
            methods.sort(String::compareTo);
        } catch (ClassNotFoundException e) {
            log.error("Could not get class for name {} Check that the plugin has declared the required dependencies!", fqn);
        }
    }

    private boolean isLambda(String s) {
        return s.contains("lambda$");
    }

    public DomainObject(Class<?> clazz, String description) {
        this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
    }

    public DomainObject(Class<?> clazz) {
        this(clazz, null);
    }

    private String formatMethodName(Method method) {
        final String replaceOld = method.getReturnType().getName();
        final String replaceNew = method.getReturnType().getSimpleName();
        final String remove = String.format("%s.%s.", packageName, className);
        String s = method.toString().replace(remove, "").replace(replaceOld, replaceNew);
        for (Class clazz: method.getParameterTypes()) {
            if (clazz.isArray()) {
                String name = clazz.getName().replace("[L", "").replace(";", "").concat("[]");
                String replace = clazz.getSimpleName();
                s = s.replace(name, replace);
            } else {
                s = s.replace(clazz.getName(), clazz.getSimpleName());
            }
        }
        return s;
    }

    public String getPackageName() {
        return packageName;
    }
{'fraction_non_alphanumeric': 0.11770039898440333, 'fraction_numerical': 0.0018135654697134566, 'mean_word_length': 2.7877747252747254, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2141142', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1446, 'n_words': 352}