Program: 53277
Project: 53277
Buggy source:
private Module createModuleForProjectConfig(ProjectConfigRule projectConfig) throws IOException {
  BuildRule projectRule=projectConfig.getProjectRule();
  Buildable buildable=projectRule.getBuildable();
  Preconditions.checkState(projectRule instanceof JavaLibraryRule || projectRule instanceof AndroidLibraryRule || projectRule instanceof AndroidResourceRule|| projectRule instanceof AndroidBinaryRule|| buildable instanceof NdkLibrary,"String_Node_Str",projectRule.getType().getName());
  LinkedHashSet<DependentModule> dependencies=Sets.newLinkedHashSet();
  final BuildTarget target=projectConfig.getBuildTarget();
  Module module=new Module(projectRule,target);
  module.name=getIntellijNameForRule(projectRule);
  module.isIntelliJPlugin=projectConfig.getIsIntelliJPlugin();
  String relativePath=projectConfig.getBuildTarget().getBasePathWithSlash();
  module.pathToImlFile=String.format("String_Node_Str",relativePath,module.name);
  boolean includeSourceFolder=true;
  boolean hasSourceFoldersForTestRule=addSourceFolders(module,projectConfig.getTestRule(),projectConfig.getTestsSourceRoots(),true);
  BuildRule testRule=projectConfig.getTestRule();
  if (testRule != null) {
    walkRuleAndAdd(testRule,true,dependencies,projectConfig.getSrcRule());
  }
  boolean hasSourceFoldersForSrcRule=addSourceFolders(module,projectConfig.getSrcRule(),projectConfig.getSourceRoots(),false);
  if (!hasSourceFoldersForTestRule && !hasSourceFoldersForSrcRule) {
    includeSourceFolder=false;
  }
  boolean isAndroidRule=projectRule.getProperties().is(ANDROID);
  if (isAndroidRule) {
    boolean hasSourceFolders=!module.sourceFolders.isEmpty();
    module.sourceFolders.add(SourceFolder.GEN);
    if (!hasSourceFolders) {
      includeSourceFolder=true;
    }
  }
  walkRuleAndAdd(projectRule,false,dependencies,projectConfig.getSrcRule());
  String basePathWithSlash=projectConfig.getBuildTarget().getBasePathWithSlash();
  module.moduleGenPath=generateRelativeGenPath(basePathWithSlash).toString();
  DependentModule jdkDependency;
  if (isAndroidRule) {
    if (projectRule.getBuildable() instanceof NdkLibrary) {
      NdkLibrary ndkLibrary=(NdkLibrary)projectRule.getBuildable();
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
      module.nativeLibs=Paths.get(relativePath).relativize(Paths.get(ndkLibrary.getLibraryPath())).toString();
    }
 else     if (projectRule instanceof AndroidResourceRule) {
      AndroidResourceRule androidResourceRule=(AndroidResourceRule)projectRule;
      module.resFolder=createRelativePath(androidResourceRule.getRes(),target);
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
    }
 else     if (projectRule instanceof AndroidBinaryRule) {
      AndroidBinaryRule androidBinaryRule=(AndroidBinaryRule)projectRule;
      module.resFolder=null;
      module.isAndroidLibraryProject=false;
      KeystoreProperties keystoreProperties=KeystoreProperties.createFromPropertiesFile(androidBinaryRule.getKeystore().getPathToStore(),androidBinaryRule.getKeystore().getPathToPropertiesFile(),projectFilesystem);
      module.keystorePath=Paths.get(relativePath).relativize(Paths.get(keystoreProperties.getKeystore())).toString();
    }
 else {
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
    }
    module.hasAndroidFacet=true;
    module.proguardConfigPath=null;
    if (pathToDefaultAndroidManifest.isPresent()) {
      String androidManifest=basePathWithSlash + "String_Node_Str";
      if (!projectFilesystem.exists(androidManifest)) {
        String manifestPath=this.pathToDefaultAndroidManifest.get();
        String rootPrefix="String_Node_Str";
        Preconditions.checkState(manifestPath.startsWith(rootPrefix),"String_Node_Str" + "String_Node_Str",rootPrefix);
        manifestPath=manifestPath.substring(rootPrefix.length());
        String relativePathToManifest=Paths.get(basePathWithSlash).relativize(Paths.get(manifestPath)).toString();
        module.androidManifest="String_Node_Str" + relativePathToManifest;
      }
    }
    jdkDependency=DependentModule.newInheritedJdk();
  }
 else {
    module.hasAndroidFacet=false;
    if (module.isIntelliJPlugin()) {
      jdkDependency=DependentModule.newIntelliJPluginJdk();
    }
 else {
      jdkDependency=DependentModule.newStandardJdk();
    }
  }
  module.dependencies=createDependenciesInOrder(includeSourceFolder,dependencies,jdkDependency);
  if (projectRule instanceof JavaLibraryRule) {
    JavaLibraryRule javaLibraryRule=(JavaLibraryRule)projectRule;
    AnnotationProcessingData processingData=javaLibraryRule.getAnnotationProcessingData();
    String annotationGenSrc=processingData.getGeneratedSourceFolderName();
    if (annotationGenSrc != null) {
      module.annotationGenPath="String_Node_Str" + Paths.get(basePathWithSlash).relativize(Paths.get(annotationGenSrc)).toString();
      module.annotationGenIsForTest=!hasSourceFoldersForSrcRule;
    }
  }
  return module;
}

Fixed version (ground truth):
private Module createModuleForProjectConfig(ProjectConfigRule projectConfig) throws IOException {
  BuildRule projectRule=projectConfig.getProjectRule();
  Buildable buildable=projectRule.getBuildable();
  Preconditions.checkState(projectRule instanceof JavaLibraryRule || projectRule instanceof JavaBinaryRule || projectRule instanceof AndroidLibraryRule|| projectRule instanceof AndroidResourceRule|| projectRule instanceof AndroidBinaryRule|| buildable instanceof NdkLibrary,"String_Node_Str",projectRule.getType().getName());
  LinkedHashSet<DependentModule> dependencies=Sets.newLinkedHashSet();
  final BuildTarget target=projectConfig.getBuildTarget();
  Module module=new Module(projectRule,target);
  module.name=getIntellijNameForRule(projectRule);
  module.isIntelliJPlugin=projectConfig.getIsIntelliJPlugin();
  String relativePath=projectConfig.getBuildTarget().getBasePathWithSlash();
  module.pathToImlFile=String.format("String_Node_Str",relativePath,module.name);
  boolean includeSourceFolder=true;
  boolean hasSourceFoldersForTestRule=addSourceFolders(module,projectConfig.getTestRule(),projectConfig.getTestsSourceRoots(),true);
  BuildRule testRule=projectConfig.getTestRule();
  if (testRule != null) {
    walkRuleAndAdd(testRule,true,dependencies,projectConfig.getSrcRule());
  }
  boolean hasSourceFoldersForSrcRule=addSourceFolders(module,projectConfig.getSrcRule(),projectConfig.getSourceRoots(),false);
  addRootExcludes(module,projectConfig.getSrcRule());
  if (!hasSourceFoldersForTestRule && !hasSourceFoldersForSrcRule) {
    includeSourceFolder=false;
  }
  boolean isAndroidRule=projectRule.getProperties().is(ANDROID);
  if (isAndroidRule) {
    boolean hasSourceFolders=!module.sourceFolders.isEmpty();
    module.sourceFolders.add(SourceFolder.GEN);
    if (!hasSourceFolders) {
      includeSourceFolder=true;
    }
  }
  walkRuleAndAdd(projectRule,false,dependencies,projectConfig.getSrcRule());
  String basePathWithSlash=projectConfig.getBuildTarget().getBasePathWithSlash();
  module.moduleGenPath=generateRelativeGenPath(basePathWithSlash).toString();
  DependentModule jdkDependency;
  if (isAndroidRule) {
    if (projectRule.getBuildable() instanceof NdkLibrary) {
      NdkLibrary ndkLibrary=(NdkLibrary)projectRule.getBuildable();
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
      module.nativeLibs=Paths.get(relativePath).relativize(Paths.get(ndkLibrary.getLibraryPath())).toString();
    }
 else     if (projectRule instanceof AndroidResourceRule) {
      AndroidResourceRule androidResourceRule=(AndroidResourceRule)projectRule;
      module.resFolder=createRelativePath(androidResourceRule.getRes(),target);
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
    }
 else     if (projectRule instanceof AndroidBinaryRule) {
      AndroidBinaryRule androidBinaryRule=(AndroidBinaryRule)projectRule;
      module.resFolder=null;
      module.isAndroidLibraryProject=false;
      KeystoreProperties keystoreProperties=KeystoreProperties.createFromPropertiesFile(androidBinaryRule.getKeystore().getPathToStore(),androidBinaryRule.getKeystore().getPathToPropertiesFile(),projectFilesystem);
      module.keystorePath=Paths.get(relativePath).relativize(Paths.get(keystoreProperties.getKeystore())).toString();
    }
 else {
      module.isAndroidLibraryProject=true;
      module.keystorePath=null;
    }
    module.hasAndroidFacet=true;
    module.proguardConfigPath=null;
    if (pathToDefaultAndroidManifest.isPresent()) {
      String androidManifest=basePathWithSlash + "String_Node_Str";
      if (!projectFilesystem.exists(androidManifest)) {
        String manifestPath=this.pathToDefaultAndroidManifest.get();
        String rootPrefix="String_Node_Str";
        Preconditions.checkState(manifestPath.startsWith(rootPrefix),"String_Node_Str" + "String_Node_Str",rootPrefix);
        manifestPath=manifestPath.substring(rootPrefix.length());
        String relativePathToManifest=Paths.get(basePathWithSlash).relativize(Paths.get(manifestPath)).toString();
        module.androidManifest="String_Node_Str" + relativePathToManifest;
      }
    }
    jdkDependency=DependentModule.newInheritedJdk();
  }
 else {
    module.hasAndroidFacet=false;
    if (module.isIntelliJPlugin()) {
      jdkDependency=DependentModule.newIntelliJPluginJdk();
    }
 else {
      jdkDependency=DependentModule.newStandardJdk();
    }
  }
  module.dependencies=createDependenciesInOrder(includeSourceFolder,dependencies,jdkDependency);
  if (projectRule instanceof JavaLibraryRule) {
    JavaLibraryRule javaLibraryRule=(JavaLibraryRule)projectRule;
    AnnotationProcessingData processingData=javaLibraryRule.getAnnotationProcessingData();
    String annotationGenSrc=processingData.getGeneratedSourceFolderName();
    if (annotationGenSrc != null) {
      module.annotationGenPath="String_Node_Str" + Paths.get(basePathWithSlash).relativize(Paths.get(annotationGenSrc)).toString();
      module.annotationGenIsForTest=!hasSourceFoldersForSrcRule;
    }
  }
  return module;
}