Collection<MetricEvent> (InspectionToolWrapper<?, ?> tool, PluginInfo pluginInfo, boolean inspectionEnabled) { if (!isSafeToReport(pluginInfo)) { return Collections.emptyList(); } if (!tool.isInitialized()) { // trade-off : we would like to not trigger class loading and instantiation of unnecessary inspections return Collections.emptyList(); } InspectionProfileEntry entry = tool.getTool(); Map<String, Attribute> options = getOptions(entry); if (options.isEmpty()) { return Collections.emptyList(); } Set<String> fields = ContainerUtil.map2Set(ReflectionUtil.collectFields(entry.getClass()), f -> f.getName()); Map<String, Attribute> defaultOptions = getOptions(ReflectionUtil.newInstance(entry.getClass())); Collection<MetricEvent> result = new ArrayList<>(); String inspectionId = tool.getID(); for (Map.Entry<String, Attribute> option : options.entrySet()) { String name = option.getKey(); Attribute value = option.getValue(); if (fields.contains(name) && value != null) { Attribute defaultValue = defaultOptions.get(name); if (defaultValue == null || !StringUtil.equals(value.getValue(), defaultValue.getValue())) { final var settingPair = getSettingValue(value); if (settingPair == null) continue; result.add(SETTING_NON_DEFAULT_STATE.metric( INSPECTION_ID_FIELD.with(inspectionId), INSPECTION_ENABLED_FIELD.with(inspectionEnabled), EventFields.PluginInfo.with(pluginInfo), settingPair.first, settingPair.second, OPTION_NAME_FIELD.with(name) )); } } } return result; }