@@ -0,0 +1,2993 @@
+package edu.hm.hafner.analysis.parser;%0A%0Aimport java.io.IOException;%0Aimport java.io.Reader;%0A%0Aimport org.json.JSONArray;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0Aimport org.json.JSONTokener;%0A%0Aimport edu.hm.hafner.analysis.Issue;%0Aimport edu.hm.hafner.analysis.IssueBuilder;%0Aimport edu.hm.hafner.analysis.IssueParser;%0Aimport edu.hm.hafner.analysis.ParsingException;%0Aimport edu.hm.hafner.analysis.ReaderFactory;%0Aimport edu.hm.hafner.analysis.Report;%0Aimport edu.hm.hafner.analysis.Severity;%0A%0Apublic class BrakemanParser extends IssueParser %7B%0A    private static final long serialVersionUID = 1374428573878091300L;%0A%0A    @Override%0A    public boolean accepts(final ReaderFactory readerFactory) %7B%0A        return readerFactory.getFileName().endsWith(%22.json%22);%0A    %7D%0A%0A    @Override%0A    public Report parse(final ReaderFactory readerFactory) throws ParsingException %7B%0A        final Report report = new Report();%0A        try (Reader reader = readerFactory.create()) %7B%0A            final JSONObject jsonReport = (JSONObject) new JSONTokener(reader).nextValue();%0A%0A            final JSONArray warnings = jsonReport.getJSONArray(%22warnings%22);%0A            for (Object warning : warnings) %7B%0A                report.add(convertToIssue((JSONObject) warning));%0A            %7D%0A        %7D%0A        catch (IOException %7C JSONException %7C ClassCastException e) %7B%0A            throw new ParsingException(e);%0A        %7D%0A        return report;%0A    %7D%0A%0A    private Issue convertToIssue(JSONObject warning) throws JSONException %7B%0A        String fileName = warning.getString(%22file%22);%0A        String category = warning.getString(%22warning_type%22);%0A        Severity severity = getSeverity(warning.getString(%22confidence%22));%0A        String fingerprint = warning.getString(%22fingerprint%22);%0A        String warning_type = warning.getString(%22check_name%22);%0A        StringBuilder message = new StringBuilder();%0A        message.append(warning.getString(%22message%22));%0A%0A        if(warning.has(%22code%22)) %7B%0A            String code = warning.optString(%22code%22, %22%22);%0A%0A            if(!code.isEmpty()) %7B%0A                message.%0A                    append(%22: %22).%0A                    append(warning.getString(%22code%22));%0A            %7D%0A        %7D%0A%0A        int line = warning.optInt(%22line%22, 1);%0A%0A        return new IssueBuilder()%0A            .setMessage(message.toString())%0A            .setCategory(category)%0A            .setType(warning_type)%0A            .setSeverity(severity)%0A            .setFileName(fileName)%0A            .setLineStart(line)%0A            .setFingerprint(fingerprint)%0A            .build();%0A    %7D%0A%0A    private Severity getSeverity(String confidence) %7B%0A        if (%22Medium%22.equalsIgnoreCase(confidence)) %7B%0A            return Severity.WARNING_NORMAL;%0A        %7D else if (%22High%22.equalsIgnoreCase(confidence)) %7B%0A            return Severity.WARNING_HIGH;%0A        %7D else if (%22Weak%22.equalsIgnoreCase(confidence)) %7B%0A            return Severity.WARNING_LOW;%0A        %7D%0A        else %7B%0A            return Severity.WARNING_HIGH;%0A        %7D%0A    %7D%0A%7D%0A

Add parser for Brakeman JSON reports