public boolean isGloballyEnabled() { if (isCorePlugin()) { return true; } switch (enabled) { case ENABLED: return true; case DISABLED: return false; case PLUGIN_DEFAULT: return isEnabledByDefault(); default: throw new IllegalStateException("Unknown state : " + enabled); } }
public void setGloballyEnabled(boolean enabled) { if (isCorePlugin()) { if (!enabled) { throw new IllegalArgumentException("Can't disable core plugin");
private DetectorFactoryCollection(boolean loadCore, boolean forceLoad, @Nonnull Collection<Plugin> pluginsToLoad, @Nonnull Collection<Plugin> enabledPlugins) { if(loadCore) { loadCorePlugin(); } for(Plugin plugin : pluginsToLoad) { if (forceLoad || plugin.isGloballyEnabled() && !plugin.isCorePlugin()) { loadPlugin(plugin); if(!enabledPlugins.contains(plugin)) { enabledPlugins.add(plugin); } } } setGlobalOptions(); // There are too many places where the detector factory collection can be created, // and in many cases it has nothing to do with update checks, like Plugin#addCustomPlugin(URI). // Line below commented to allow custom plugins be loaded/registered BEFORE we // start to update something. The reason is that custom plugins // can disable update globally OR just will be NOT INCLUDED in the update check! // updateChecker.checkForUpdates(pluginsToUpdate, false); }
private static int findRankUnknownPlugin(BugPattern pattern) { List<BugRanker> rankers = new ArrayList<>(); pluginLoop: for (Plugin plugin : Plugin.getAllPlugins()) { if (plugin.isCorePlugin()) { continue; } if (false) { rankers.add(plugin.getBugRanker()); continue pluginLoop; } for (DetectorFactory df : plugin.getDetectorFactories()) { if (df.getReportedBugPatterns().contains(pattern)) { if (PLUGIN_DEBUG) { System.out.println("Bug rank match " + plugin + " " + df + " for " + pattern); } rankers.add(plugin.getBugRanker()); continue pluginLoop; } } if (PLUGIN_DEBUG) { System.out.println("plugin " + plugin + " doesn't match " + pattern); } } rankers.add(getCoreRanker()); return rankBugPattern(pattern, rankers.toArray(new BugRanker[rankers.size()])); }
LOG.info("Plugin {}, version {}, loaded from {}", plugin.getPluginId(), plugin.getVersion(), plugin.getPluginLoader().getURL()); if (plugin.isCorePlugin()) { LOG.info(" is core plugin");
public boolean isGloballyEnabled() { if (isCorePlugin()) { return true; } switch (enabled) { case ENABLED: return true; case DISABLED: return false; case PLUGIN_DEFAULT: return isEnabledByDefault(); default: throw new IllegalStateException("Unknown state : " + enabled); } }
private UpdateChecker.PluginUpdate sortUpdates(Collection<UpdateChecker.PluginUpdate> updates, List<UpdateChecker.PluginUpdate> sorted) { UpdateChecker.PluginUpdate core = null; for (UpdateChecker.PluginUpdate update : updates) { if (update.getPlugin().isCorePlugin()) { core = update; } else { sorted.add(update); } } // sort by name Collections.sort(sorted, new Comparator<UpdateChecker.PluginUpdate>() { @Override public int compare(UpdateChecker.PluginUpdate o1, UpdateChecker.PluginUpdate o2) { return o1.getPlugin().getShortDescription().compareTo(o2.getPlugin().getShortDescription()); } }); // place core plugin first, if present if (core != null) { sorted.add(0, core); } return core; }
private JLabel createPluginLabel(UpdateChecker.PluginUpdate update) { String name; if (update.getPlugin().isCorePlugin()) { name = "FindBugs"; } else { name = update.getPlugin().getShortDescription(); } JLabel label = new JLabel(MessageFormat.format( "<html><b>{0} {2}</b> is available<br><i><small>(currently installed: {1})", name, update.getPlugin().getVersion(), update.getVersion())); label.setFont(label.getFont().deriveFont(Font.PLAIN, label.getFont().getSize() + 4)); return label; }
@Override public String toString() { SimpleDateFormat format = new SimpleDateFormat(PLUGIN_RELEASE_DATE_FMT); StringBuilder buf = new StringBuilder(); String name = getPlugin().isCorePlugin() ? "FindBugs" : "FindBugs plugin " + getPlugin().getShortDescription(); buf.append( name + " " + getVersion() ); if (date == null) { buf.append(" has been released"); } else { buf.append(" was released " + format.format(date)); } buf.append( " (you have " + getPlugin().getVersion() + ")"); buf.append("\n"); buf.append(" " + message.replaceAll("\n", "\n ")); if (url != null) { buf.append("\nVisit " + url + " for details."); } return buf.toString(); } }
public void setGloballyEnabled(boolean enabled) { if (isCorePlugin()) { if (!enabled) { throw new IllegalArgumentException("Can't disable core plugin");
private static int findRankUnknownPlugin(BugPattern pattern) { List<BugRanker> rankers = new ArrayList<BugRanker>(); pluginLoop: for (Plugin plugin : Plugin.getAllPlugins()) { if (plugin.isCorePlugin()) { continue; } if (false) { rankers.add(plugin.getBugRanker()); continue pluginLoop; } for (DetectorFactory df : plugin.getDetectorFactories()) { if (df.getReportedBugPatterns().contains(pattern)) { if (PLUGIN_DEBUG) { System.out.println("Bug rank match " + plugin + " " + df + " for " + pattern); } rankers.add(plugin.getBugRanker()); continue pluginLoop; } } if (PLUGIN_DEBUG) { System.out.println("plugin " + plugin + " doesn't match " + pattern); } } rankers.add(getCoreRanker()); return rankBugPattern(pattern, rankers.toArray(new BugRanker[rankers.size()])); }
private DetectorFactoryCollection(boolean loadCore, boolean forceLoad, @Nonnull Collection<Plugin> pluginsToLoad, @Nonnull Collection<Plugin> enabledPlugins) { if(loadCore) { loadCorePlugin(); } for(Plugin plugin : pluginsToLoad) { if (forceLoad || plugin.isGloballyEnabled() && !plugin.isCorePlugin()) { loadPlugin(plugin); if(!enabledPlugins.contains(plugin)) { enabledPlugins.add(plugin); } } } setGlobalOptions(); updateChecker = new UpdateChecker(this); pluginsToUpdate = combine(enabledPlugins); // There are too many places where the detector factory collection can be created, // and in many cases it has nothing to do with update checks, like Plugin#addCustomPlugin(URI). // Line below commented to allow custom plugins be loaded/registered BEFORE we // start to update something. The reason is that custom plugins // can disable update globally OR just will be NOT INCLUDED in the update check! // updateChecker.checkForUpdates(pluginsToUpdate, false); }
int added = 0; for (final Plugin plugin : plugins) { if (plugin.isCorePlugin()) { continue;
System.out.printf("Plugin %s, version %s, loaded from %s%n", plugin.getPluginId(), plugin.getVersion(), plugin.getPluginLoader().getURL()); if (plugin.isCorePlugin()) { System.out.println(" is core plugin");