<commit_before>/*
 * Copyright 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.bramhaag.discordselfbot.commands.util;

import lombok.NonNull;
import me.bramhaag.discordselfbot.commands.Command;
import me.bramhaag.discordselfbot.util.JavadocParser;
import me.bramhaag.discordselfbot.util.Util;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.net.URL;
import java.util.Arrays;

public class CommandJavadoc {

    @Command(name = "javadoc", aliases = { "doc", "jd" }, minArgs = 1)
    public void execute(@NonNull Message message, @NonNull TextChannel channel, @NonNull String[] args) {
        String[] parts = args[0].split("\\.");

        //String path = StringUtils.join(Arrays.copyOf(parts, parts.length - 1), "/");
        //String method = parts[parts.length - 1];

        String pack = parts.length >= 3 ? StringUtils.join(Arrays.copyOf(parts, parts.length - 2), "/") + "/" : null;
        String clazz = parts[parts.length - 2];
        String method = args[0].contains(".") ? args[0].substring(args[0].lastIndexOf(".") + 1, args[0].length()) : args[0];

        JavadocParser.JavadocResult result = null;

        try {
            if(pack == null) {
                result = JavadocParser.getJavadoc(clazz + "/" + method);
            }
            else {
                result = args.length > 1 ? JavadocParser.getJavadoc(args[1], pack + clazz, method) : JavadocParser.getJavadoc(pack + clazz, method);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        if(result == null) {
            Util.sendError(message, "Result is null!");
        }

        EmbedBuilder builder = new EmbedBuilder().setTitle("Javadoc", null)
                                                 .addField("Name", code(result.getName()), false)
                                                 .addField("Format", code(result.getFormat()), false)
                                                 .addField("Description", code(result.getDescription()), false);

        result.getFields().forEach((key, value) -> builder.addField(key, code(StringUtils.join(value, "\n")), false));
        channel.sendMessage(builder.build()).queue();
    }

    private String code(String input) {
        return "```" + input + "```";
    }
}
<commit_msg>Test for Jenkins 2<commit_after>/*
 * Copyright 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.bramhaag.discordselfbot.commands.util;

import lombok.NonNull;
import me.bramhaag.discordselfbot.commands.Command;
import me.bramhaag.discordselfbot.util.JavadocParser;
import me.bramhaag.discordselfbot.util.Util;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.net.URL;
import java.util.Arrays;

public class CommandJavadoc {

    @Command(name = "javadoc", aliases = { "doc", "jd" }, minArgs = 1)
    public void execute(@NonNull Message message, @NonNull TextChannel channel, @NonNull String[] args) {
        String[] parts = args[0].split("\\.");

        String pack = parts.length >= 3 ? StringUtils.join(Arrays.copyOf(parts, parts.length - 2), "/") + "/" : null;
        String clazz = parts[parts.length - 2];
        String method = args[0].contains(".") ? args[0].substring(args[0].lastIndexOf(".") + 1, args[0].length()) : args[0];

        JavadocParser.JavadocResult result = null;

        try {
            if(pack == null) {
                result = JavadocParser.getJavadoc(clazz + "/" + method);
            }
            else {
                result = args.length > 1 ? JavadocParser.getJavadoc(args[1], pack + clazz, method) : JavadocParser.getJavadoc(pack + clazz, method);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        if(result == null) {
            Util.sendError(message, "Result is null!");
        }

        EmbedBuilder builder = new EmbedBuilder().setTitle("Javadoc", null)
                                                 .addField("Name", code(result.getName()), false)
                                                 .addField("Format", code(result.getFormat()), false)
                                                 .addField("Description", code(result.getDescription()), false);

        result.getFields().forEach((key, value) -> builder.addField(key, code(StringUtils.join(value, "\n")), false));
        channel.sendMessage(builder.build()).queue();
    }

    private String code(String input) {
        return "```" + input + "```";
    }
}

{'fraction_non_alphanumeric': 0.13108293351610692, 'fraction_numerical': 0.0090815627141878, 'mean_word_length': 2.607540173053152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4335092', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1640, 'n_words': 424}