Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.SortedBugCollection


        if (args.length != 1) {
            System.out.println("Usage: " + ListErrors.class.getName() + " <bug collection>");
            System.exit(1);
        }
        FindBugs.setNoAnalysis();
        SortedBugCollection bugCollection = new SortedBugCollection();
        bugCollection.readXML(args[0]);
        for (AnalysisError e : bugCollection.getErrors()) {
            String msg = e.getExceptionMessage();
            if (msg != null && msg.trim().length() > 0) {
                System.out.println(e.getMessage() + " : " + msg);
            } else {
                System.out.println(e.getMessage());
View Full Code Here


        out.close();
    }

    private static void listVersion(PrintWriter out, @CheckForNull String fileName, boolean formatDates) throws IOException,
    DocumentException {
        SortedBugCollection origCollection;
        origCollection = new SortedBugCollection();

        if (fileName == null) {
            origCollection.readXML(System.in);
        } else {
            origCollection.readXML(fileName);
        }
        AppVersion appVersion = origCollection.getCurrentAppVersion();
        ProjectStats stats = origCollection.getProjectStats();
        out.print(appVersion.getReleaseName());
        out.print('\t');
        if (formatDates) {
            out.print("\"" + new Date(appVersion.getTimestamp()) + "\"");
        } else {
            out.print(appVersion.getTimestamp());
        }
        out.print('\t');

        out.print(appVersion.getNumClasses());
        out.print('\t');
        out.print(appVersion.getCodeSize());
        out.print('\t');
        out.print(origCollection.getErrors().size());
        out.print('\t');
        out.print(stats.getTotalBugs());
        out.print('\t');
        out.print(stats.getBugsOfPriority(Priorities.HIGH_PRIORITY));
        out.print('\t');
View Full Code Here

        RebornIssues reborn = new RebornIssues();
        CommandLine commandLine = new CommandLine();
        int argCount = commandLine.parse(args, 0, 2, "Usage: " + RebornIssues.class.getName()
                + " [options] [<xml results> [<history]] ");

        SortedBugCollection bugCollection = new SortedBugCollection();
        if (argCount < args.length) {
            bugCollection.readXML(args[argCount++]);
        } else {
            bugCollection.readXML(System.in);
        }
        reborn.setBugCollection(bugCollection);
        reborn.execute();

    }
View Full Code Here

        if (args.length != 1) {
            System.out.println("Usage: " + PrintAppVersion.class.getName() + " <bug collection>");
            System.exit(1);
        }
        FindBugs.setNoAnalysis();
        SortedBugCollection bugCollection = new SortedBugCollection();
        bugCollection.readXML(args[0]);
        System.out.println(bugCollection.getCurrentAppVersion());
    }
View Full Code Here

            System.out.println(USAGE);
            return;
        }

        int prefixLength = Integer.parseInt(args[0]);
        BugCollection origCollection = new SortedBugCollection();
        if (args.length == 1) {
            origCollection.readXML(System.in);
        } else {
            origCollection.readXML(args[1]);
        }
        Map<String, Integer> map = new TreeMap<String, Integer>();
        Map<String, Integer> ncss = new TreeMap<String, Integer>();

        for (BugInstance b : origCollection.getCollection()) {
            String prefix = ClassName.extractPackagePrefix(b.getPrimaryClass().getPackageName(), prefixLength);
            Integer v = map.get(prefix);
            if (v == null) {
                map.put(prefix, 1);
            } else {
                map.put(prefix, v + 1);
            }
        }
        for (PackageStats ps : origCollection.getProjectStats().getPackageStats()) {
            String prefix = ClassName.extractPackagePrefix(ps.getPackageName(), prefixLength);

            Integer v = ncss.get(prefix);
            if (v == null) {
                ncss.put(prefix, ps.size());
View Full Code Here

            commonPrefix = Math.min(commonPrefix, lengthCommonPrefix(firstPathParts, getFilePathParts(args[i])));
        }

        String origFilename = args[argCount++];
        BugCollection origCollection;
        origCollection = new SortedBugCollection();
        if (verbose) {
            System.out.println("Starting with " + origFilename);
        }

        while (true) {
            try {
                while (true) {
                    File f = new File(origFilename);
                    if (f.length() > 0) {
                        break;
                    }
                    if (verbose) {
                        System.out.println("Empty input file: " + f);
                    }
                    origFilename = args[argCount++];
                }
                origCollection.readXML(origFilename);
                break;
            } catch (Exception e) {
                if (verbose) {
                    System.out.println("Error reading " + origFilename);
                    e.printStackTrace(System.out);
                }
                origFilename = args[argCount++];
            }
        }

        if (commandLine.overrideRevisionNames || origCollection.getReleaseName() == null
                || origCollection.getReleaseName().length() == 0) {

            if (commonPrefix >= firstPathParts.length) {
                // This should only happen if either
                //
                // (1) there is only one input file, or
                // (2) all of the input files have the same name
                //
                // In either case, make the release name the same
                // as the file part of the input file(s).
                commonPrefix = firstPathParts.length - 1;
            }

            origCollection.setReleaseName(firstPathParts[commonPrefix]);
            if (useAnalysisTimes) {
                origCollection.setTimestamp(origCollection.getAnalysisTimestamp());
            }
        }

        for (BugInstance bug : origCollection.getCollection()) {
            if (bug.getLastVersion() >= 0 && bug.getFirstVersion() > bug.getLastVersion()) {
                throw new IllegalStateException("Illegal Version range: " + bug.getFirstVersion() + ".." + bug.getLastVersion());
            }
        }

        discardUnwantedBugs(origCollection);

        while (argCount <= (args.length - 1)) {

            BugCollection newCollection = new SortedBugCollection();

            String newFilename = args[argCount++];
            if (verbose) {
                System.out.println("Merging " + newFilename);
            }
            try {
                File f = new File(newFilename);
                if (f.length() == 0) {
                    if (verbose) {
                        System.out.println("Empty input file: " + f);
                    }
                    continue;
                }
                newCollection.readXML(newFilename);

                if (commandLine.overrideRevisionNames || newCollection.getReleaseName() == null
                        || newCollection.getReleaseName().length() == 0) {
                    newCollection.setReleaseName(getFilePathParts(newFilename)[commonPrefix]);
                }
                if (useAnalysisTimes) {
                    newCollection.setTimestamp(newCollection.getAnalysisTimestamp());
                }
                discardUnwantedBugs(newCollection);

                origCollection = mergeCollections(origCollection, newCollection, true, false);
            } catch (IOException e) {
View Full Code Here

        // detector plugins
    }

    static public SortedBugCollection union(SortedBugCollection origCollection, SortedBugCollection newCollection) {

        SortedBugCollection result = origCollection.duplicate();

        for (Iterator<BugInstance> i = newCollection.iterator(); i.hasNext();) {
            BugInstance bugInstance = i.next();
            result.add(bugInstance);
        }
        ProjectStats stats = result.getProjectStats();
        ProjectStats stats2 = newCollection.getProjectStats();
        stats.addStats(stats2);

        Project project = result.getProject();
        project.add(newCollection.getProject());

        return result;
    }
View Full Code Here

        }

        IGuiCallback cliUiCallback = new CommandLineUiCallback();
        for (String analysisFile : options.analysisFiles) {
            try {
                SortedBugCollection more = createPreconfiguredBugCollection(options.workingDirList, options.srcDirList,
                        cliUiCallback);

                more.readXML(analysisFile);
                BugRanker.trimToMaxRank(more, options.maxConsideredRank);
                if (results != null) {
                    results = union(results, more);
                } else {
                    results = more;
View Full Code Here

        }
        for (String srcDir : srcDirList) {
            project.addSourceDir(srcDir);
        }
        project.setGuiCallback(guiCallback);
        return new SortedBugCollection(project);
    }
View Full Code Here

        if (args.length > 1 || (args.length > 0 && "-help".equals(args[0]))) {
            System.err.println("Usage: " + DefectDensity.class.getName() + " [<infile>]");
            System.exit(1);
        }
        FindBugs.setNoAnalysis();
        BugCollection origCollection = new SortedBugCollection();
        int argCount = 0;
        if (argCount == args.length) {
            origCollection.readXML(System.in);
        } else {
            origCollection.readXML(args[argCount]);
        }
        ProjectStats stats = origCollection.getProjectStats();
        printRow("kind", "name", "density/KNCSS", "bugs", "NCSS");
        double projectDensity = density(stats.getTotalBugs(), stats.getCodeSize());
        printRow("project", origCollection.getCurrentAppVersion().getReleaseName(), projectDensity, stats.getTotalBugs(),
                stats.getCodeSize());
        for (PackageStats p : stats.getPackageStats()) {
            if (p.getTotalBugs() > 4) {

                double packageDensity = density(p.getTotalBugs(), p.size());
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.SortedBugCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.