Codota Logo
FilePredicates.or
Code IndexAdd Codota to your IDE (free)

How to use
or
method
in
org.sonar.api.batch.fs.FilePredicates

Best Java code snippets using org.sonar.api.batch.fs.FilePredicates.or (Showing top 15 results out of 315)

  • Common ways to obtain FilePredicates
private void myMethod () {
FilePredicates f =
  • Codota IconFileSystem fs;fs.predicates()
  • Codota IconSensorContext context;context.fileSystem().predicates()
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

@Test
public void or() {
 // empty
 assertThat(predicates.or().apply(javaFile)).isTrue();
 assertThat(predicates.or(new FilePredicate[0]).apply(javaFile)).isTrue();
 assertThat(predicates.or(Collections.<FilePredicate>emptyList()).apply(javaFile)).isTrue();
 // two arguments
 assertThat(predicates.or(predicates.all(), predicates.all()).apply(javaFile)).isTrue();
 assertThat(predicates.or(predicates.all(), predicates.none()).apply(javaFile)).isTrue();
 assertThat(predicates.or(predicates.none(), predicates.all()).apply(javaFile)).isTrue();
 assertThat(predicates.or(predicates.none(), predicates.none()).apply(javaFile)).isFalse();
 // collection
 assertThat(predicates.or(Arrays.asList(predicates.all(), predicates.all())).apply(javaFile)).isTrue();
 assertThat(predicates.or(Arrays.asList(predicates.all(), predicates.none())).apply(javaFile)).isTrue();
 assertThat(predicates.or(Arrays.asList(predicates.none(), predicates.none())).apply(javaFile)).isFalse();
 // array
 assertThat(predicates.or(new FilePredicate[] {predicates.all(), predicates.all()}).apply(javaFile)).isTrue();
 assertThat(predicates.or(new FilePredicate[] {predicates.all(), predicates.none()}).apply(javaFile)).isTrue();
 assertThat(predicates.or(new FilePredicate[] {predicates.none(), predicates.none()}).apply(javaFile)).isFalse();
}
origin: pmayweg/sonar-groovy

private static FilePredicate getFileNamePredicateFromSuffixes(FilePredicates p, String fileName, String[] suffixes) {
 List<FilePredicate> fileNamePredicates = new ArrayList<>(suffixes.length);
 for (String suffix : suffixes) {
  fileNamePredicates.add(p.matchesPathPattern("**/" + fileName + suffix));
 }
 return p.or(fileNamePredicates);
}
origin: fr.sii.sonar/sonar-report-core

private static FilePredicate filterTypePredicate(FileSystem fileSystem, Type... types) {
  FilePredicates predicatesFactory = fileSystem.predicates();
  Collection<FilePredicate> typePredicates = new ArrayList<FilePredicate>(types.length);
  for (Type type : types) {
    typePredicates.add(predicatesFactory.hasType(type));
  }
  return typePredicates.isEmpty() ? predicatesFactory.all() : predicatesFactory.or(typePredicates);
}

origin: org.codehaus.sonar/sonar-batch

private FilePredicate fromDeprecatedAttribute(String key, Collection<String> value) {
 if ("TYPE".equals(key)) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
origin: org.sonarsource.sonarqube/sonar-batch

private FilePredicate fromDeprecatedAttribute(String key, Collection<String> value) {
 if ("TYPE".equals(key)) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
  return predicates().or(Collections2.transform(value, new Function<String, FilePredicate>() {
   @Override
   public FilePredicate apply(@Nullable String s) {
origin: fr.sii.sonar/sonar-report-core

private static FilePredicate searchFilePredicate(FileSystem fileSystem, String path) {
  FilePredicates predicatesFactory = fileSystem.predicates();
  Collection<FilePredicate> searchPredicates = new ArrayList<FilePredicate>();
  // try to find the file directly using the provided path (absolute or
  // relative)
  searchPredicates.add(predicatesFactory.hasPath(path));
  // if not found, maybe the path starts with '/'
  // in this case, Sonar thinks it's an absolute path => manually try
  // relative
  if (path.startsWith("/")) {
    searchPredicates.add(predicatesFactory.hasRelativePath(path.substring(1)));
  }
  // if not found, try to search it everywhere
  searchPredicates.add(predicatesFactory.matchesPathPattern("**" + path));
  return predicatesFactory.or(searchPredicates);
}
origin: Cognifide/AEM-Rules-for-SonarQube

public static FilePredicate createFilePredicate(Configuration configuration, SensorContext sensorContext) {
  FilePredicates predicates = sensorContext.fileSystem().predicates();
  List<FilePredicate> fileExtensions = getFileExtensionsPredicates(predicates, configuration);
  List<FilePredicate> relativePaths = getPathsPredicate(predicates, configuration);
  return predicates.and(
    predicates.hasType(InputFile.Type.MAIN),
    predicates.or(
      predicates.hasLanguages(Htl.KEY),
      predicates.or(fileExtensions)
    ),
    predicates.or(relativePaths)
  );
}
origin: racodond/sonar-css-plugin

private FilePredicate mainFilePredicate(FileSystem fileSystem) {
 String[] suffixes = getSettings().getStringArray(Plugin.EMBEDDED_CSS_FILE_SUFFIXES_KEY);
 if (suffixes == null || suffixes.length == 0) {
  suffixes = StringUtils.split(Plugin.CSS_FILE_SUFFIXES_DEFAULT_VALUE, ",");
 }
 List<FilePredicate> filePredicates = new ArrayList<>();
 for (String suffix : suffixes) {
  filePredicates.add(fileSystem.predicates().matchesPathPattern("**/*." + suffix));
 }
 return fileSystem.predicates().or(filePredicates);
}
origin: org.codehaus.sonar/sonar-batch

 private FilePredicate newHasLanguagesPredicate(Language... languages) {
  List<FilePredicate> list = Lists.newArrayList();
  for (Language language : languages) {
   list.add(target.predicates().hasLanguage(language.getKey()));
  }
  return target.predicates().or(list);
 }
}
origin: uartois/sonar-golang

public static List<InputFile> searchFileWithTypeMainOrTest(final SensorContext context) {
FilePredicates predicate = context.fileSystem().predicates();
Iterable<InputFile> iter = context.fileSystem().inputFiles(predicate.and(predicate.hasLanguage(GoLanguage.KEY),
  predicate.or(predicate.hasType(InputFile.Type.MAIN), predicate.hasType(InputFile.Type.TEST))));
final List<InputFile> listFiles = new ArrayList<>();
iter.forEach(listFiles::add);
return listFiles;
}
origin: SonarSource/SonarJS

private static InputFile getInputFile(SensorContext context, String fileName) {
 FilePredicates predicates = context.fileSystem().predicates();
 InputFile inputFile = context.fileSystem().inputFile(predicates.or(predicates.hasRelativePath(fileName), predicates.hasAbsolutePath(fileName)));
 if (inputFile == null) {
  LOG.warn("No input file found for {}. No {} issues will be imported on this file.", fileName, LINTER_NAME);
  return null;
 }
 return inputFile;
}
origin: org.sonarsource.javascript/sonar-javascript-plugin

private static InputFile getInputFile(SensorContext context, String fileName) {
 FilePredicates predicates = context.fileSystem().predicates();
 InputFile inputFile = context.fileSystem().inputFile(predicates.or(predicates.hasRelativePath(fileName), predicates.hasAbsolutePath(fileName)));
 if (inputFile == null) {
  LOG.warn("No input file found for {}. No {} issues will be imported on this file.", fileName, LINTER_NAME);
  return null;
 }
 return inputFile;
}
origin: SonarSource/sonar-html

predicates.and(
 predicates.hasType(InputFile.Type.MAIN),
 predicates.or(
  predicates.hasLanguages(HtmlConstants.LANGUAGE_KEY, HtmlConstants.JSP_LANGUAGE_KEY),
  predicates.or(Stream.of(OTHER_FILE_SUFFIXES).map(predicates::hasExtension).toArray(FilePredicate[]::new))
origin: SonarSource/sonar-go

InputFile getInputFile(SensorContext context, String filePath) {
 FilePredicates predicates = context.fileSystem().predicates();
 InputFile inputFile = context.fileSystem().inputFile(predicates.or(predicates.hasRelativePath(filePath), predicates.hasAbsolutePath(filePath)));
 if (inputFile == null) {
  LOG.warn(logPrefix() + "No input file found for {}. No {} issues will be imported on this file.", filePath, linterName());
  return null;
 }
 return inputFile;
}
origin: spotbugs/sonar-findbugs

/**
 * Determine if the project has Java source files. This is used to determine if the project has no compiled classes on
 * purpose or because the compilation was omit from the process.
 * @return If at least one Java file is present
 */
private boolean hasSourceFiles() {
 FilePredicates pred = fileSystem.predicates();
 return fileSystem.hasFiles(
     pred.and(
         pred.hasType(Type.MAIN),
         pred.or(FindbugsPlugin.getSupportedLanguagesFilePredicate(pred)),
         //package-info.java will not generate any class files.
         //See: https://github.com/SonarQubeCommunity/sonar-findbugs/issues/36
         pred.not(pred.matchesPathPattern("**/package-info.java")),
         pred.not(pred.matchesPathPattern("**/module-info.java")),
         pred.not(pred.matchesPathPattern("**/*.jsp"))
     )
 );
}
org.sonar.api.batch.fsFilePredicatesor

Popular methods of FilePredicates

  • hasLanguage
  • and
  • hasType
  • hasPath
    if the parameter represents an absolute path for the running environment, then returns #hasAbsoluteP
  • hasAbsolutePath
    Predicate that find file by its absolute path. The parameter accepts forward/back slashes as separat
  • hasRelativePath
    Predicate that gets a file by its relative path. The parameter accepts forward/back slashes as separ
  • all
    Predicate that always evaluates to true
  • matchesPathPattern
    Predicate that gets the files which "path" matches a wildcard pattern. The path is the path part of
  • hasLanguages
  • is
    Warning - may not be supported in SonarLint
  • hasStatus
    Look for InputFile having a specific InputFile#status()
  • doesNotMatchPathPatterns
    Predicate that gets the files that do not match any of the given wildcard patterns. No filter is app
  • hasStatus,
  • doesNotMatchPathPatterns,
  • not,
  • hasAnyStatus,
  • matchesPathPatterns,
  • doesNotMatchPathPattern,
  • hasExtension,
  • hasFilename,
  • hasURI

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • runOnUiThread (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now