Program: 23163
Project: 23163
Buggy source:
private int checkElement(List<ValidationMessage> errors,String path,ElementDefn e,ResourceDefn parent,String parentName,boolean needsRimMapping,boolean optionalParent,boolean hasSummary,List<String> vsWarns,boolean parentInSummary) throws Exception {
  e.setPath(path);
  int vsWarnings=0;
  if (!names.containsKey(e.getName()))   names.put(e.getName(),0);
  names.put(e.getName(),names.get(e.getName()) + 1);
  rule(errors,IssueType.STRUCTURE,path,e.getName().length() < maxElementLength,"String_Node_Str" + e.getName() + "String_Node_Str"+ Integer.toString(maxElementLength));
  rule(errors,IssueType.STRUCTURE,path,isValidToken(e.getName(),!path.contains("String_Node_Str")),"String_Node_Str" + e.getName() + "String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.unbounded() || e.getMaxCardinality() == 1,"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0 || e.getMinCardinality() == 1,"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str") || e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (!hasSummary)   e.setSummaryItem(true);
 else   if (parentInSummary) {
    rule(errors,IssueType.STRUCTURE,path,hasSummary(e) || !e.isModifier(),"String_Node_Str" + path + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,hasSummary(e) || e.getMinCardinality() == 0,"String_Node_Str" + path + "String_Node_Str");
  }
  rule(errors,IssueType.STRUCTURE,path,optionalParent || e.isSummary() || !path.contains("String_Node_Str")|| e.getMinCardinality() == 0,"String_Node_Str" + path + "String_Node_Str");
  optionalParent=optionalParent || e.getMinCardinality() == 0;
  hint(errors,IssueType.STRUCTURE,path,!nameOverlaps(e.getName(),parentName),"String_Node_Str" + e.getName() + "String_Node_Str"+ parentName+ "String_Node_Str");
  checkDefinitions(errors,path,e);
  warning(errors,IssueType.STRUCTURE,path,!path.contains("String_Node_Str") || !Utilities.isPlural(e.getName()) || !e.unbounded(),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().endsWith("String_Node_Str") || !e.unbounded(),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,(parentName == null) || e.getName().charAt(0) == e.getName().toLowerCase().charAt(0),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getName().equals(path) || e.getElements().size() == 0 || (e.hasSvg() || e.isUmlBreak() || !Utilities.noString(e.getUmlDir())),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getDefinition().toLowerCase().startsWith("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getDefinition().endsWith("String_Node_Str") || e.getDefinition().endsWith("String_Node_Str"),"String_Node_Str" + e.getDefinition() + "String_Node_Str");
  if (e.usesType("String_Node_Str") && e.usesType("String_Node_Str"))   rule(errors,IssueType.STRUCTURE,path,e.hasComments() && e.getComments().contains("String_Node_Str") && e.getComments().contains("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.BUSINESSRULE,path,Utilities.noString(e.getTodo()),"String_Node_Str" + e.getTodo() + "String_Node_Str");
  if (!Utilities.noString(e.getW5())) {
    if (path.contains("String_Node_Str"))     rule(errors,IssueType.INVALID,path,definitions.getW5s().containsKey(e.getW5()),"String_Node_Str" + e.getW5() + "String_Node_Str");
 else {
      String[] vs=e.getW5().split("String_Node_Str");
      rule(errors,IssueType.INVALID,path,vs.length == 2 && definitions.getW5s().containsKey(vs[0]) && definitions.getW5s().get(vs[0]).getSubClasses().contains(vs[1]),"String_Node_Str" + e.getW5() + "String_Node_Str");
    }
  }
  if (e.getName().equals("String_Node_Str"))   warning(errors,IssueType.STRUCTURE,path,!e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (e.getName().equals("String_Node_Str"))   rule(errors,IssueType.STRUCTURE,path,e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (e.getName().equals("String_Node_Str")) {
    warning(errors,IssueType.STRUCTURE,path,isOkComment(path),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.typeCode().equals("String_Node_Str"),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0,"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMaxCardinality() == 1,"String_Node_Str");
  }
  if (e.getName().equals("String_Node_Str")) {
    warning(errors,IssueType.STRUCTURE,path,e.typeCode().equals("String_Node_Str"),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0,"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.unbounded(),"String_Node_Str");
  }
  String sd=e.getShortDefn();
  if (sd.length() > 0) {
    rule(errors,IssueType.STRUCTURE,path,sd.contains("String_Node_Str") || Character.isUpperCase(sd.charAt(0)) || sd.startsWith("String_Node_Str")|| !Character.isLetter(sd.charAt(0))|| Utilities.isURL(sd)|| sd.startsWith("String_Node_Str"),"String_Node_Str" + sd + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,!sd.endsWith("String_Node_Str") || sd.endsWith("String_Node_Str"),"String_Node_Str" + sd + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,e.getDefinition().contains("String_Node_Str") || Character.isUpperCase(e.getDefinition().charAt(0)) || !Character.isLetter(e.getDefinition().charAt(0)),"String_Node_Str" + e.getDefinition() + "String_Node_Str");
  }
  for (  String inv : e.getInvariants().keySet()) {
    String xpath=e.getInvariants().get(inv).getXpath();
    rule(errors,IssueType.VALUE,path,!(xpath.contains("String_Node_Str") || xpath.contains("String_Node_Str")),"String_Node_Str");
  }
  rule(errors,IssueType.STRUCTURE,path,!e.getName().startsWith("String_Node_Str"),"String_Node_Str");
  checkType(errors,path,e,parent);
  rule(errors,IssueType.STRUCTURE,path,!"String_Node_Str".equals(e.typeCode()),"String_Node_Str");
  if (e.typeCode().equals("String_Node_Str") && parent != null && !e.isNoBindingAllowed()) {
    rule(errors,IssueType.STRUCTURE,path,e.hasBinding(),"String_Node_Str");
  }
  if ((e.usesType("String_Node_Str") && !parentName.equals("String_Node_Str")) || (e.usesType("String_Node_Str") && !(e.usesType("String_Node_Str") || e.usesType("String_Node_Str") || e.usesType("String_Node_Str")))) {
    hint(errors,IssueType.STRUCTURE,path,e.hasBinding(),"String_Node_Str");
  }
  if (e.getTypes().size() > 1) {
    Set<String> types=new HashSet<String>();
    for (    TypeRef t : e.getTypes()) {
      String base=null;
      if (definitions.getConstraints().containsKey(t.getName()))       base=definitions.getConstraints().get(t.getName()).getBaseType();
 else       base=t.getName();
      rule(errors,IssueType.STRUCTURE,path,!types.contains(base),"String_Node_Str");
      types.add(base);
    }
  }
  if (e.hasBinding()) {
    boolean ok=false;
    for (    TypeRef tr : e.getTypes()) {
      ok=ok || Utilities.existsInList(tr.getName(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    }
    rule(errors,IssueType.STRUCTURE,path,ok,"String_Node_Str" + e.typeCode() + "String_Node_Str");
    if (e.getBinding().getValueSet() != null && e.getBinding().getValueSet().getName() == null)     throw new Error("String_Node_Str" + e.getBinding().getName());
    BindingSpecification cd=e.getBinding();
    if (cd != null) {
      check(errors,path,cd,sd,e);
      if (cd.getValueSet() != null) {
        if (e.getBinding().getStrength() == BindingStrength.EXAMPLE)         ValueSetUtilities.markStatus(cd.getValueSet(),parent == null ? "String_Node_Str" : parent.getWg().getCode(),StandardsStatus.DRAFT,null,"String_Node_Str");
 else         if (parent == null)         ValueSetUtilities.markStatus(cd.getValueSet(),"String_Node_Str",StandardsStatus.DRAFT,null,"String_Node_Str");
 else         ValueSetUtilities.markStatus(cd.getValueSet(),parent.getWg().getCode(),parent.getStatus(),parent.getNormativePackage(),parent.getFmmLevel());
        Integer w=(Integer)cd.getValueSet().getUserData("String_Node_Str");
        if (w != null && w > 0 && !vsWarns.contains(cd.getValueSet().getId())) {
          vsWarnings++;
          vsWarns.add(cd.getValueSet().getId());
        }
      }
    }
  }
  String s=e.getMapping(Definitions.RIM_MAPPING);
  hint(errors,IssueType.REQUIRED,path,!needsRimMapping || !Utilities.noString(s),"String_Node_Str");
  needsRimMapping=needsRimMapping && !"String_Node_Str".equalsIgnoreCase(s) && !Utilities.noString(s);
  for (  String uri : definitions.getMapTypes().keySet()) {
    MappingSpace m=definitions.getMapTypes().get(uri);
    if (m.isPattern()) {
      String map=e.getMapping(uri);
      if (!Utilities.noString(map)) {
        String err=checkPatternMap(e,map);
        rule(errors,IssueType.STRUCTURE,path,err == null,"String_Node_Str" + m.getTitle() + "String_Node_Str"+ path+ "String_Node_Str"+ err);
      }
    }
  }
  for (  ElementDefn c : e.getElements()) {
    String name=c.getName();
    if (name.endsWith("String_Node_Str")) {
      name=name.substring(0,name.length() - 3);
      for (      ElementDefn c2 : e.getElements()) {
        if (c != c2)         rule(errors,IssueType.STRUCTURE,path,!c2.getName().startsWith(name) || !definitions.hasType(c2.getName().substring(name.length())),"String_Node_Str" + c.getName() + "String_Node_Str"+ c2.getName()+ "String_Node_Str"+ path);
      }
    }
  }
  for (  ElementDefn c : e.getElements()) {
    vsWarnings=vsWarnings + checkElement(errors,path + "String_Node_Str" + c.getName(),c,parent,e.getName(),needsRimMapping,optionalParent,hasSummary,vsWarns,parentInSummary && hasSummary(e));
  }
  return vsWarnings;
}

Fixed version (ground truth):
private int checkElement(List<ValidationMessage> errors,String path,ElementDefn e,ResourceDefn parent,String parentName,boolean needsRimMapping,boolean optionalParent,boolean hasSummary,List<String> vsWarns,boolean parentInSummary) throws Exception {
  e.setPath(path);
  int vsWarnings=0;
  if (!names.containsKey(e.getName()))   names.put(e.getName(),0);
  names.put(e.getName(),names.get(e.getName()) + 1);
  rule(errors,IssueType.STRUCTURE,path,e.getName().length() < maxElementLength,"String_Node_Str" + e.getName() + "String_Node_Str"+ Integer.toString(maxElementLength));
  rule(errors,IssueType.STRUCTURE,path,isValidToken(e.getName(),!path.contains("String_Node_Str")),"String_Node_Str" + e.getName() + "String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.unbounded() || e.getMaxCardinality() == 1,"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0 || e.getMinCardinality() == 1,"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str") || e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (!hasSummary)   e.setSummaryItem(true);
 else   if (parentInSummary) {
    rule(errors,IssueType.STRUCTURE,path,hasSummary(e) || !e.isModifier(),"String_Node_Str" + path + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,hasSummary(e) || e.getMinCardinality() == 0,"String_Node_Str" + path + "String_Node_Str");
  }
  rule(errors,IssueType.STRUCTURE,path,optionalParent || e.isSummary() || !path.contains("String_Node_Str")|| e.getMinCardinality() == 0,"String_Node_Str" + path + "String_Node_Str");
  optionalParent=optionalParent || e.getMinCardinality() == 0;
  hint(errors,IssueType.STRUCTURE,path,!nameOverlaps(e.getName(),parentName),"String_Node_Str" + e.getName() + "String_Node_Str"+ parentName+ "String_Node_Str");
  checkDefinitions(errors,path,e);
  warning(errors,IssueType.STRUCTURE,path,!path.contains("String_Node_Str") || !Utilities.isPlural(e.getName()) || !e.unbounded(),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().endsWith("String_Node_Str") || !e.unbounded(),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getName().equals("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,(parentName == null) || e.getName().charAt(0) == e.getName().toLowerCase().charAt(0),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getName().equals(path) || e.getElements().size() == 0 || (e.hasSvg() || e.isUmlBreak() || !Utilities.noString(e.getUmlDir())),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,!e.getDefinition().toLowerCase().startsWith("String_Node_Str"),"String_Node_Str");
  rule(errors,IssueType.STRUCTURE,path,e.getDefinition().endsWith("String_Node_Str") || e.getDefinition().endsWith("String_Node_Str"),"String_Node_Str" + e.getDefinition() + "String_Node_Str");
  if (e.usesType("String_Node_Str") && e.usesType("String_Node_Str"))   rule(errors,IssueType.STRUCTURE,path,e.hasComments() && e.getComments().contains("String_Node_Str") && e.getComments().contains("String_Node_Str"),"String_Node_Str");
  warning(errors,IssueType.BUSINESSRULE,path,Utilities.noString(e.getTodo()),"String_Node_Str" + e.getTodo() + "String_Node_Str");
  if (!Utilities.noString(e.getW5())) {
    if (path.contains("String_Node_Str"))     rule(errors,IssueType.INVALID,path,definitions.getW5s().containsKey(e.getW5()),"String_Node_Str" + e.getW5() + "String_Node_Str");
 else {
      String[] vs=e.getW5().split("String_Node_Str");
      rule(errors,IssueType.INVALID,path,vs.length == 2 && definitions.getW5s().containsKey(vs[0]) && definitions.getW5s().get(vs[0]).getSubClasses().contains(vs[1]),"String_Node_Str" + e.getW5() + "String_Node_Str");
    }
  }
  if (e.getName().equals("String_Node_Str"))   warning(errors,IssueType.STRUCTURE,path,!e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (e.getName().equals("String_Node_Str"))   rule(errors,IssueType.STRUCTURE,path,e.typeCode().equals("String_Node_Str"),"String_Node_Str");
  if (e.getName().equals("String_Node_Str")) {
    warning(errors,IssueType.STRUCTURE,path,isOkComment(path),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,Utilities.existsInList(e.typeCode(),"String_Node_Str","String_Node_Str"),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0,"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMaxCardinality() == 1,"String_Node_Str");
  }
  if (e.getName().equals("String_Node_Str")) {
    warning(errors,IssueType.STRUCTURE,path,e.typeCode().equals("String_Node_Str"),"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.getMinCardinality() == 0,"String_Node_Str");
    warning(errors,IssueType.STRUCTURE,path,e.unbounded(),"String_Node_Str");
  }
  String sd=e.getShortDefn();
  if (sd.length() > 0) {
    rule(errors,IssueType.STRUCTURE,path,sd.contains("String_Node_Str") || Character.isUpperCase(sd.charAt(0)) || sd.startsWith("String_Node_Str")|| !Character.isLetter(sd.charAt(0))|| Utilities.isURL(sd)|| sd.startsWith("String_Node_Str"),"String_Node_Str" + sd + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,!sd.endsWith("String_Node_Str") || sd.endsWith("String_Node_Str"),"String_Node_Str" + sd + "String_Node_Str");
    rule(errors,IssueType.STRUCTURE,path,e.getDefinition().contains("String_Node_Str") || Character.isUpperCase(e.getDefinition().charAt(0)) || !Character.isLetter(e.getDefinition().charAt(0)),"String_Node_Str" + e.getDefinition() + "String_Node_Str");
  }
  for (  String inv : e.getInvariants().keySet()) {
    String xpath=e.getInvariants().get(inv).getXpath();
    rule(errors,IssueType.VALUE,path,!(xpath.contains("String_Node_Str") || xpath.contains("String_Node_Str")),"String_Node_Str");
  }
  rule(errors,IssueType.STRUCTURE,path,!e.getName().startsWith("String_Node_Str"),"String_Node_Str");
  checkType(errors,path,e,parent);
  rule(errors,IssueType.STRUCTURE,path,!"String_Node_Str".equals(e.typeCode()),"String_Node_Str");
  if (e.typeCode().equals("String_Node_Str") && parent != null && !e.isNoBindingAllowed()) {
    rule(errors,IssueType.STRUCTURE,path,e.hasBinding(),"String_Node_Str");
  }
  if ((e.usesType("String_Node_Str") && !parentName.equals("String_Node_Str")) || (e.usesType("String_Node_Str") && !(e.usesType("String_Node_Str") || e.usesType("String_Node_Str") || e.usesType("String_Node_Str")))) {
    hint(errors,IssueType.STRUCTURE,path,e.hasBinding(),"String_Node_Str");
  }
  if (e.getTypes().size() > 1) {
    Set<String> types=new HashSet<String>();
    for (    TypeRef t : e.getTypes()) {
      String base=null;
      if (definitions.getConstraints().containsKey(t.getName()))       base=definitions.getConstraints().get(t.getName()).getBaseType();
 else       base=t.getName();
      rule(errors,IssueType.STRUCTURE,path,!types.contains(base),"String_Node_Str");
      types.add(base);
    }
  }
  if (e.hasBinding()) {
    boolean ok=false;
    for (    TypeRef tr : e.getTypes()) {
      ok=ok || Utilities.existsInList(tr.getName(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    }
    rule(errors,IssueType.STRUCTURE,path,ok,"String_Node_Str" + e.typeCode() + "String_Node_Str");
    if (e.getBinding().getValueSet() != null && e.getBinding().getValueSet().getName() == null)     throw new Error("String_Node_Str" + e.getBinding().getName());
    BindingSpecification cd=e.getBinding();
    if (cd != null) {
      check(errors,path,cd,sd,e);
      if (cd.getValueSet() != null) {
        if (e.getBinding().getStrength() == BindingStrength.EXAMPLE)         ValueSetUtilities.markStatus(cd.getValueSet(),parent == null ? "String_Node_Str" : parent.getWg().getCode(),StandardsStatus.DRAFT,null,"String_Node_Str");
 else         if (parent == null)         ValueSetUtilities.markStatus(cd.getValueSet(),"String_Node_Str",StandardsStatus.DRAFT,null,"String_Node_Str");
 else         ValueSetUtilities.markStatus(cd.getValueSet(),parent.getWg().getCode(),parent.getStatus(),parent.getNormativePackage(),parent.getFmmLevel());
        Integer w=(Integer)cd.getValueSet().getUserData("String_Node_Str");
        if (w != null && w > 0 && !vsWarns.contains(cd.getValueSet().getId())) {
          vsWarnings++;
          vsWarns.add(cd.getValueSet().getId());
        }
      }
    }
  }
  String s=e.getMapping(Definitions.RIM_MAPPING);
  hint(errors,IssueType.REQUIRED,path,!needsRimMapping || !Utilities.noString(s),"String_Node_Str");
  needsRimMapping=needsRimMapping && !"String_Node_Str".equalsIgnoreCase(s) && !Utilities.noString(s);
  for (  String uri : definitions.getMapTypes().keySet()) {
    MappingSpace m=definitions.getMapTypes().get(uri);
    if (m.isPattern()) {
      String map=e.getMapping(uri);
      if (!Utilities.noString(map)) {
        String err=checkPatternMap(e,map);
        rule(errors,IssueType.STRUCTURE,path,err == null,"String_Node_Str" + m.getTitle() + "String_Node_Str"+ path+ "String_Node_Str"+ err);
      }
    }
  }
  for (  ElementDefn c : e.getElements()) {
    String name=c.getName();
    if (name.endsWith("String_Node_Str")) {
      name=name.substring(0,name.length() - 3);
      for (      ElementDefn c2 : e.getElements()) {
        if (c != c2)         rule(errors,IssueType.STRUCTURE,path,!c2.getName().startsWith(name) || !definitions.hasType(c2.getName().substring(name.length())),"String_Node_Str" + c.getName() + "String_Node_Str"+ c2.getName()+ "String_Node_Str"+ path);
      }
    }
  }
  for (  ElementDefn c : e.getElements()) {
    vsWarnings=vsWarnings + checkElement(errors,path + "String_Node_Str" + c.getName(),c,parent,e.getName(),needsRimMapping,optionalParent,hasSummary,vsWarns,parentInSummary && hasSummary(e));
  }
  return vsWarnings;
}