Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.SortedBugCollection


    final StringBuilder html = new StringBuilder();
    html.append("<html><body>");
    html.append("<h2>");
    html.append(bugInstance.getAbridgedMessage());
    html.append("</h2><p/>");
    final SortedBugCollection bc = _lastBugCollection;
    if (bc != null) {
      final Cloud cloud = bc.getCloud();
      //noinspection ConstantConditions
      if (cloud != null) {
        final int reviewers = cloud.getReviewers(bugInstance).size();
        if (reviewers > 0) {
          html.append(" - <a href='#comments'><u>");
View Full Code Here


        setProgressIndicator(indicator);
        indicator.setFraction(0.0);
        indicator.setIndeterminate(false);
        indicator.setText(fileToImport);
        try {
          _bugCollection = new SortedBugCollection();
          final FindBugsPlugin pluginComponent = IdeaUtilImpl.getPluginComponent(project);
          _importBugCollection = _bugCollection.createEmptyCollectionWithMetadata();
          final edu.umd.cs.findbugs.Project importProject = _importBugCollection.getProject();
          importProject.setGuiCallback(new PluginGuiCallback(pluginComponent));
          _importBugCollection.setDoNotUseCloud(true);
View Full Code Here

    }

    final FindBugsPlugin pluginComponent = IdeaUtilImpl.getPluginComponent(_project);
    _findBugsProject.setGuiCallback(new PluginGuiCallback(pluginComponent));

    _bugCollection = new SortedBugCollection(_findBugsProject);
    _bugCollection.setDoNotUseCloud(true);

    //CompilerManager.getInstance(_project).addCompilationStatusListener(this);

    //initCollectorTask(_findBugsProject);
View Full Code Here

        DetectorFactoryCollection.instance(); // as a side effect, loads
        // detector plugins
    }

    static public SortedBugCollection union(SortedBugCollection origCollection, SortedBugCollection newCollection) {
        SortedBugCollection result = origCollection.duplicate();
        merge(null, result, newCollection);
        return result;
    }
View Full Code Here

        final UnionResultsCommandLine commandLine = new UnionResultsCommandLine();

        int argCount = commandLine.parse(argv, 2, Integer.MAX_VALUE, "Usage: " + UnionResults.class.getName()
                + " [options] [<results1> <results2> ... <resultsn>] ");

        SortedBugCollection results = null;
        HashSet<String> hashes = new HashSet<String>();

        for (int i = argCount; i < argv.length; i++) {
            try {
                SortedBugCollection more = new SortedBugCollection();

                more.readXML(argv[i]);
                if (results == null) {
                    results = more.createEmptyCollectionWithMetadata();
                }

                merge(hashes, results, more);

            } catch (IOException e) {
View Full Code Here

        final FilterCommandLine commandLine = new FilterCommandLine();

        int argCount = commandLine.parse(args, 0, 2, "Usage: " + Filter.class.getName()
                + " [options] [<orig results> [<new results]] ");
        SortedBugCollection origCollection = new SortedBugCollection();

        if (argCount == args.length) {
            origCollection.readXML(System.in);
        } else {
            origCollection.readXML(args[argCount++]);
        }
        boolean verbose = argCount < args.length;
        SortedBugCollection resultCollection = origCollection.createEmptyCollectionWithMetadata();
        Project project = resultCollection.getProject();
        int passed = 0;
        int dropped = 0;
        resultCollection.setWithMessages(commandLine.withMessages);
        if (commandLine.hashChangedSpecified) {
            origCollection.computeBugHashes();
        }
        commandLine.adjustFilter(project, resultCollection);
        ProjectStats projectStats = resultCollection.getProjectStats();
        projectStats.clearBugCounts();
        if (commandLine.classPattern != null) {
            projectStats.purgeClassesThatDontMatch(commandLine.classPattern);
        }
        sourceSearcher = new SourceSearcher(project);

        long trimToVersion = -1;
        if (commandLine.trimToVersionAsString != null) {
            Map<String, AppVersion> versions = new HashMap<String, AppVersion>();
            SortedMap<Long, AppVersion> timeStamps = new TreeMap<Long, AppVersion>();

            for (Iterator<AppVersion> i = origCollection.appVersionIterator(); i.hasNext();) {
                AppVersion v = i.next();
                versions.put(v.getReleaseName(), v);
                timeStamps.put(v.getTimestamp(), v);
            }
            // add current version to the maps
            AppVersion v = resultCollection.getCurrentAppVersion();
            versions.put(v.getReleaseName(), v);
            timeStamps.put(v.getTimestamp(), v);

            trimToVersion = edu.umd.cs.findbugs.workflow.Filter.FilterCommandLine.getVersionNum(versions, timeStamps,
                    commandLine.trimToVersionAsString, true, v.getSequenceNumber());
            if (trimToVersion < origCollection.getSequenceNumber()) {
                String name = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getReleaseName();
                long timestamp = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getTimestamp();
                resultCollection.setReleaseName(name);
                resultCollection.setTimestamp(timestamp);
                resultCollection.trimAppVersions(trimToVersion);
            }

        }

        if (commandLine.maxAgeSpecified || commandLine.notAProblemSpecified || commandLine.shouldFixSpecified) {

            Cloud cloud = origCollection.getCloud();
            SigninState signinState = cloud.getSigninState();
            if (!signinState.canDownload()) {
                disconnect(verbose, commandLine, resultCollection,  cloud.getCloudName() + " state is " + signinState
                        + "; ignoring filtering options that require cloud access");

            } else if (!cloud.waitUntilIssueDataDownloaded(20, TimeUnit.SECONDS)) {
                if (verbose) {
                    System.out.println("Waiting for cloud information required for filtering");
                }
                if (!cloud.waitUntilIssueDataDownloaded(60, TimeUnit.SECONDS)) {
                    disconnect(verbose, commandLine, resultCollection,
                            "Unable to connect to cloud; ignoring filtering options that require cloud access");
                }
            }
        }

        commandLine.getReady(origCollection);

        for (BugInstance bug : origCollection.getCollection()) {
            if (commandLine.accept(origCollection, bug)) {
                if (trimToVersion >= 0) {
                    if (bug.getFirstVersion() > trimToVersion) {
                        dropped++;
                        continue;
                    } else if (bug.getLastVersion() >= trimToVersion) {
                        bug.setLastVersion(-1);
                        bug.setRemovedByChangeOfPersistingClass(false);
                    }
                }
                resultCollection.add(bug, false);
                passed++;
            } else {
                dropped++;
            }
        }

        if (commandLine.purgeHistorySpecified && commandLine.purgeHistory) {
            resultCollection.clearAppVersions();
            for (BugInstance bug : resultCollection.getCollection()) {
                bug.clearHistory();
            }


        }
        if (verbose) {
            System.out.println(passed + " warnings passed through, " + dropped + " warnings dropped");
        }
        if (commandLine.withSourceSpecified && commandLine.withSource && !commandLine.dontUpdateStats
                && projectStats.hasClassStats()) {
            for (PackageStats stats : projectStats.getPackageStats()) {
                Iterator<ClassStats> i = stats.getClassStats().iterator();
                while (i.hasNext()) {
                    String className = i.next().getName();
                    if (sourceSearcher.sourceNotFound.contains(className) || !sourceSearcher.sourceFound.contains(className)
                            && !sourceSearcher.findSource(SourceLineAnnotation.createReallyUnknown(className))) {
                        i.remove();
                    }
                }
            }

        }
        projectStats.recomputeFromComponents();
        if (argCount == args.length) {
            assert !verbose;
            resultCollection.writeXML(System.out);
        } else {
            resultCollection.writeXML(args[argCount++]);

        }

    }
View Full Code Here

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

        BugCollection origCollection;
        origCollection = new SortedBugCollection();
        origCollection.readXML(args[0]);
        SourceFinder sourceFinder = new SourceFinder(origCollection.getProject());

        for (BugInstance b : origCollection) {
            SourceLineAnnotation s = b.getPrimarySourceLineAnnotation();
View Full Code Here

        FindBugs.setNoAnalysis();
        DetectorFactoryCollection.instance();
        SetInfoCommandLine commandLine = new SetInfoCommandLine();
        int argCount = commandLine.parse(args, 0, 2, USAGE);

        SortedBugCollection origCollection = new SortedBugCollection();

        if (argCount < args.length) {
            origCollection.readXML(args[argCount++]);
        } else {
            origCollection.readXML(System.in);
        }
        Project project = origCollection.getProject();

        if (commandLine.revisionName != null) {
            origCollection.setReleaseName(commandLine.revisionName);
        }
        if (commandLine.projectName != null) {
            origCollection.getProject().setProjectName(commandLine.projectName);
        }
        if (commandLine.revisionTimestamp != 0) {
            origCollection.setTimestamp(commandLine.revisionTimestamp);
        }
        origCollection.setWithMessages(commandLine.withMessages);

        if (commandLine.purgeDesignations) {
            for (BugInstance b : origCollection) {
                b.setUserDesignation(null);
            }
        }
        if (commandLine.exclusionFilterFile != null) {
            project.setSuppressionFilter(Filter.parseFilter(commandLine.exclusionFilterFile));
        }
        if (commandLine.resetProject) {
            project.getSourceDirList().clear();
            project.getFileList().clear();
            project.getAuxClasspathEntryList().clear();
        }
        boolean reinitializeCloud = false;
        if (commandLine.cloudId != null) {
            project.setCloudId(commandLine.cloudId);
            reinitializeCloud = true;
        }
        for (Map.Entry<String, String> e : commandLine.cloudProperties.entrySet()) {
            project.getCloudProperties().setProperty(e.getKey(), e.getValue());
            reinitializeCloud = true;
        }

        if (commandLine.resetSource) {
            project.getSourceDirList().clear();
        }
        for (String source : commandLine.sourcePaths) {
            project.addSourceDir(source);
        }
        if (commandLine.purgeStats) {
            origCollection.getProjectStats().getPackageStats().clear();
        }
        if (commandLine.purgeClassStats) {
            for (PackageStats ps : origCollection.getProjectStats().getPackageStats()) {
                ps.getClassStats().clear();
            }
        }
        if (commandLine.purgeMissingClasses) {
            origCollection.clearMissingClasses();
        }
        if (commandLine.lastVersion != null) {
            long last = edu.umd.cs.findbugs.workflow.Filter.FilterCommandLine.getVersionNum(origCollection,
                    commandLine.lastVersion, true);
            if (last < origCollection.getSequenceNumber()) {
                String name = origCollection.getAppVersionFromSequenceNumber(last).getReleaseName();
                long timestamp = origCollection.getAppVersionFromSequenceNumber(last).getTimestamp();
                origCollection.setReleaseName(name);
                origCollection.setTimestamp(timestamp);
                origCollection.trimAppVersions(last);
            }

        }

        Map<String, Set<String>> missingFiles = new HashMap<String, Set<String>>();
        if (!commandLine.searchSourcePaths.isEmpty()) {
            sourceSearcher = new SourceSearcher(project);
            for (BugInstance bug : origCollection.getCollection()) {
                SourceLineAnnotation src = bug.getPrimarySourceLineAnnotation();
                if (!sourceSearcher.sourceNotFound.contains(src.getClassName()) && !sourceSearcher.findSource(src)) {
                    Set<String> paths = missingFiles.get(src.getSourceFile());
                    if (paths == null) {
                        paths = new HashSet<String>();
                        missingFiles.put(src.getSourceFile(), paths);
                    }
                    String fullPath = fullPath(src);
                    // System.out.println("Missing " + fullPath);
                    paths.add(fullPath);
                }
            }
            Set<String> foundPaths = new HashSet<String>();
            for (String f : commandLine.searchSourcePaths) {
                for (File javaFile : RecursiveSearchForJavaFiles.search(new File(f))) {
                    Set<String> matchingMissingClasses = missingFiles.get(javaFile.getName());
                    if (matchingMissingClasses == null) {
                        // System.out.println("Nothing for " + javaFile);
                    } else {
                        for (String sourcePath : matchingMissingClasses) {
                            String path = javaFile.getAbsolutePath();
                            if (path.endsWith(sourcePath)) {
                                String dir = path.substring(0, path.length() - sourcePath.length());
                                foundPaths.add(dir);

                            }
                        }
                    }

                }
            }

            Set<String> toRemove = new HashSet<String>();
            for (String p1 : foundPaths) {
                for (String p2 : foundPaths) {
                    if (!p1.equals(p2) && p1.startsWith(p2)) {
                        toRemove.add(p1);
                        break;
                    }
                }
            }
            foundPaths.removeAll(toRemove);

            for (String dir : foundPaths) {
                project.addSourceDir(dir);
                if (argCount < args.length) {
                    System.out.println("Found " + dir);
                }
            }

        }

        if (reinitializeCloud)
        {
            origCollection.clearCloud();
            // OK, now we know all the missing source files
            // we also know all the .java files in the directories we were pointed
            // to
        }

        if (argCount < args.length) {
            origCollection.writeXML(args[argCount++]);
        } else {
            origCollection.writeXML(System.out);
        }

    }
View Full Code Here

    HashSet<String> couldNotCreate = new HashSet<String>();
    int copyCount = 0;
    File dstFile;

    public CopyBuggySource(String[] args) throws Exception {
        origCollection = new SortedBugCollection();
        origCollection.readXML(args[0]);
        project = origCollection.getProject();

        sourceFinder = new SourceFinder(project);
        src = new File(args[1]);
View Full Code Here

        FindBugs.setNoAnalysis();
        CommandLine commandLine = new CommandLine();

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

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

        SortedBugCollection results = bugCollection.createEmptyCollectionWithMetadata();
        Project project = results.getProject();
        project.getSourceDirList().clear();
        project.getFileList().clear();
        project.getAuxClasspathEntryList().clear();

        results.getProjectStats().getPackageStats().clear();
        results.clearMissingClasses();
        results.clearErrors();

        for (BugInstance bug : bugCollection) {
            results.add(Obfuscate.obfuscate(bug), false);
        }

        if (argCount == args.length) {
            results.writeXML(System.out);
        } else {
            results.writeXML(args[argCount++]);

        }

    }
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.