Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.BugInstance


            if (easilySerializable < 0.9) {
                priority = LOW_PRIORITY;
            }

            bugReporter.reportBug(new BugInstance(this, "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", priority).addClass(this));

        }

    }
View Full Code Here


      case ANALYSIS_ABORTED:
      case ANALYSIS_FINISHED:
        unregisterEventListener();
        break;
      case NEW_BUG_INSTANCE:
        final BugInstance bugInstance = event.getBugInstance();
        if (bugInstance != null) {
          final ProblemDescriptor problemDescriptor = createProblemDescriptor(bugInstance);
          if (problemDescriptor != null) {
            _problems.add(problemDescriptor);
          }
View Full Code Here

  @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"})
  @SuppressWarnings({"HardCodedStringLiteral"})
  public void setBugsDetails(final BugInstanceNode bugInstanceNode, final TreePath treePath) {
    _currentTreePath = treePath;
    final BugInstance bugInstance = bugInstanceNode.getBugInstance();
    final int[] lines = BugInstanceUtil.getSourceLines(bugInstanceNode);
    final MethodAnnotation methodAnnotation = BugInstanceUtil.getPrimaryMethod(bugInstance);
    final FieldAnnotation fieldAnnotation = BugInstanceUtil.getPrimaryField(bugInstance);

    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>");
          html.append(reviewers);
          html.append(" comment");
          html.append(reviewers != 1 ? "s" : "");
          html.append("</u></a>");
        }
        final UserDesignation designation = cloud.getConsensusDesignation(bugInstance);
        if (designation != UserDesignation.UNCLASSIFIED) {
          //List<String> userDesignationKeys = I18N.instance().getUserDesignationKeys(true);
          html.append(" - \"");
          html.append(I18N.instance().getUserDesignation(designation.name()));
          html.append('\"');
        }
        final int ageInDays = (int) ((System.currentTimeMillis() - cloud.getFirstSeen(bugInstance)) / (1000 * 60 * 60 * 24));
        if (cloud.isInCloud(bugInstance) && ageInDays > 0) {
          html.append(" - first seen ");
          html.append(ageInDays);
          html.append(" day");
          html.append(ageInDays != 1 ? "s" : "");
          html.append(" ago");
        }
      }
    }

    html.append("<table border=0><tr valign=top><td valign=top>");
    html.append("<h3>Class:</h3>");
    html.append("<ul>");
    html.append("<li>");
    html.append("<a href='#class'><u>");
    html.append(BugInstanceUtil.getSimpleClassName(bugInstance));
    html.append("</u></a>");
    html.append(" <font color='gray'>(");
    final String packageName = BugInstanceUtil.getPackageName(bugInstance);
    html.append(packageName);
    html.append(")</font>");

    if (lines[0] > -1) {
      final boolean singleLine = lines[1] == lines[0];
      if (singleLine) {
        html.append(" line ");
      } else {
        html.append(" lines ");
      }
      html.append(lines[0]);
      if (!singleLine) {
        html.append('-').append(lines[1]);
      }
    }
    html.append("</ul>");

    if (methodAnnotation != null) {
      html.append("<p><h3>Method:</p>");
      html.append("<ul>");
      html.append("<li>");

      if ("<init>".equals(methodAnnotation.getMethodName())) {
        html.append(BugInstanceUtil.getJavaSourceMethodName(bugInstance)).append("&lt;init&gt; <font color='gray'>(").append(BugInstanceUtil.getFullMethod(bugInstance)).append(")</font>");
      } else {
        html.append(BugInstanceUtil.getMethodName(bugInstance)).append(" <font color='gray'>(").append(BugInstanceUtil.getFullMethod(bugInstance)).append(")</font>");
      }
      html.append("</li>");
      html.append("</ul>");
    }

    if (fieldAnnotation != null) {
      html.append("<p><h3>Field:</p>");
      html.append("<ul>");
      html.append("<li>");
      html.append(BugInstanceUtil.getFieldName(bugInstance));
      html.append("</li>");
      html.append("</ul>");
    }

    html.append("<p><h3>Priority:</p>");
    html.append("<ul>");
    html.append("<li>");
    html.append("<span width='15px' height='15px;' id='").append(BugInstanceUtil.getPriorityString(bugInstance)).append("'> &nbsp; &nbsp; </span>&nbsp;");
    html.append(BugInstanceUtil.getPriorityTypeString(bugInstance));
    html.append("</li>");
    html.append("</ul>");
    html.append("</td><td width='20px'>&nbsp;</td><td valign=top>");

    html.append("<h3>Problem classification:</h3>");
    html.append("<ul>");
    html.append("<li>");
    html.append(BugInstanceUtil.getBugCategoryDescription(bugInstance));
    html.append(" <font color='gray'>(");
    html.append(BugInstanceUtil.getBugTypeDescription(bugInstance));
    html.append(")</font>");
    html.append("</li>");
    html.append("<li>");
    html.append(BugInstanceUtil.getBugType(bugInstance));
    html.append(" <font color='gray'>(");
    html.append(BugInstanceUtil.getBugPatternShortDescription(bugInstance));
    html.append(")</font>");
    html.append("</li>");

    final Iterable<BugAnnotation> annotations = bugInstance.getAnnotationsForMessage(false);
    if (annotations.iterator().hasNext()) {
      html.append("<p><h3>Notes:</p>");
      html.append("<ul>");
      for (final BugAnnotation annotation : annotations) {
        html.append("<li>").append(annotation.toString(bugInstance.getPrimaryClass())).append("</li>");
      }
      html.append("</ul>");
    }

    final DetectorFactory detectorFactory = bugInstance.getDetectorFactory();
    if (detectorFactory != null) {
      html.append("<li>");
      html.append(detectorFactory.getShortName());
      html.append(" <font color='gray'>(");
      html.append(DetectorConfiguration.createBugsAbbreviation(detectorFactory));
View Full Code Here

    return bugInstance.getBugPattern().getDetailText();
  }


  public static int[] getSourceLines(final BugInstanceNode bugInstanceNode) {
    final BugInstance bugInstance = bugInstanceNode.getBugInstance();
    return getSourceLines(bugInstance);
  }
View Full Code Here

  public void setDetailHtml(final TreePath treePath) {
    final TreeNode treeNode = getTreeNodeFromPath(treePath);

    if (treeNode instanceof BugInstanceNode) {
      final BugInstanceNode bugNode = (BugInstanceNode) treeNode;
      final BugInstance bugInstance = bugNode.getBugInstance();

      if (_parent != null) {
        _parent.getBugDetailsComponents().setBugExplanation(_bugCollection, bugInstance);
      }
    }
View Full Code Here

  public List<BugInstance> getChildBugInstances() {
    final List<BugInstance> list = new ArrayList<BugInstance>();

    for (final TreeNode child : _childs) {
      if (child instanceof BugInstanceGroupNode) {
        final BugInstance bugInstance = ((BugInstanceGroupNode) child).getBugInstance();
        list.add(bugInstance);
      }
    }

    return list;
View Full Code Here

  public List<BugInstance> getChildBugInstances() {
    final List<BugInstance> list = new ArrayList<BugInstance>();

    for (final TreeNode child : _childs) {
      if (child instanceof BugInstanceGroupNode) {
        final BugInstance bugInstance = ((BugInstanceGroupNode) child).getBugInstance();
        list.add(bugInstance);
      }
    }

    return list;
View Full Code Here

      final List<BugInstanceGroupNode> groupNodes = entry.getValue();
      for (final BugInstanceGroupNode groupNode : groupNodes) {

        final List<VisitableTreeNode> bugInstanceNodes = groupNode.getChildsList();
        for (final VisitableTreeNode node : bugInstanceNodes) {
          final BugInstance bug = ((BugInstanceNode) node).getBugInstance();
          if (bug.equals(bugInstance)) {
            return (BugInstanceNode) node;
          }
        }
      }
    }
View Full Code Here

    }
  }


  private static void addAnnotation(final ExtendedProblemDescriptor problemDescriptor, final List<ExtendedProblemDescriptor> matchingDescriptors, final PsiElement psiElement, @NotNull final AnnotationHolder annotationHolder) {
    final BugInstance bugInstance = problemDescriptor.getBugInstance();
    final int priority = bugInstance.getPriority();
    final Annotation annotation;
    final PsiElement problemElement = problemDescriptor.getPsiElement();
    final TextRange textRange = problemElement.getTextRange();

View Full Code Here


  @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"DB_DUPLICATE_SWITCH_CLAUSES"})
  @Nullable
  public static Icon getIcon(final ExtendedProblemDescriptor problemDescriptor) {
    final BugInstance bugInstance = problemDescriptor.getBugInstance();
    final int priority = bugInstance.getPriority();
    final Icon icon;
    switch (priority) {
      case Detector.HIGH_PRIORITY :
        icon = GuiResources.PRIORITY_HIGH_ICON;
        break;
View Full Code Here

TOP

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

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.