com.google.errorprone.annotations.CheckReturnValue Java Examples
The following examples show how to use
com.google.errorprone.annotations.CheckReturnValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HealthReportBuilder.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Computes the healthiness of a build based on the specified results. Reports a health of 100% when the specified * counter is less than {@link HealthDescriptor#getHealthy()}. Reports a health of 0% when the specified counter is * greater than {@link HealthDescriptor#getUnhealthy()}. The computation takes only annotations of the specified * severity into account. * * @param healthDescriptor * health report configuration * @param labelProvider * label provider to get the messages from * @param sizePerSeverity * number of issues per severity * * @return the healthiness of a build */ @CheckReturnValue HealthReport computeHealth(final HealthDescriptor healthDescriptor, final StaticAnalysisLabelProvider labelProvider, final Map<Severity, Integer> sizePerSeverity) { int relevantIssuesSize = 0; for (Severity severity : Severity.collectSeveritiesFrom(healthDescriptor.getMinimumSeverity())) { relevantIssuesSize += sizePerSeverity.getOrDefault(severity, 0); } if (healthDescriptor.isValid()) { int percentage; int healthy = healthDescriptor.getHealthy(); if (relevantIssuesSize < healthy) { percentage = 100; } else { int unhealthy = healthDescriptor.getUnhealthy(); if (relevantIssuesSize > unhealthy) { percentage = 0; } else { percentage = 100 - ((relevantIssuesSize - healthy + 1) * 100 / (unhealthy - healthy + 2)); } } return new HealthReport(percentage, labelProvider.getToolTipLocalizable(relevantIssuesSize)); } return null; }
Example #2
Source File: ClassReader.java From turbine with Apache License 2.0 | 5 votes |
@FormatMethod @CheckReturnValue Error error(String format, Object... args) { StringBuilder sb = new StringBuilder(); if (path != null) { sb.append(path).append(": "); } sb.append(String.format(format, args)); return new AssertionError(sb.toString()); }
Example #3
Source File: VariableInitializerParser.java From turbine with Apache License 2.0 | 5 votes |
@CheckReturnValue private TurbineError error(ErrorKind kind, Object... args) { return TurbineError.format( lexer.source(), Math.min(lexer.position(), lexer.source().source().length() - 1), kind, args); }
Example #4
Source File: Parser.java From turbine with Apache License 2.0 | 5 votes |
@CheckReturnValue TurbineError error(Token token) { switch (token) { case IDENT: return error(ErrorKind.UNEXPECTED_IDENTIFIER, lexer.stringValue()); case EOF: return error(ErrorKind.UNEXPECTED_EOF); default: return error(ErrorKind.UNEXPECTED_TOKEN, token); } }
Example #5
Source File: Parser.java From turbine with Apache License 2.0 | 5 votes |
@CheckReturnValue private TurbineError error(ErrorKind kind, Object... args) { return TurbineError.format( lexer.source(), Math.min(lexer.position(), lexer.source().source().length() - 1), kind, args); }
Example #6
Source File: InMemoryFileSystem.java From bazel with Apache License 2.0 | 5 votes |
/** * Inserts inode 'childInode' into the existing directory 'dir' under the * specified 'name'. Dual to unlink. Fails if the directory was read-only. */ @CheckReturnValue private Error insert(InMemoryDirectoryInfo dir, String child, InMemoryContentInfo childInode) { if (!dir.isWritable()) { return Error.EACCES; } dir.addChild(child, childInode); return null; }
Example #7
Source File: InMemoryFileSystem.java From bazel with Apache License 2.0 | 5 votes |
/** * Version of stat that returns an InodeOrErrno of the input path. */ @CheckReturnValue protected InodeOrErrno inodeStatErrno(Path path, boolean followSymlinks) { if (followSymlinks) { return pathWalkErrno(path, false); } else { return isRootDirectory(path) ? InodeOrErrno.createInode(rootInode) : noFollowStatErrno(path); } }
Example #8
Source File: TargetPattern.java From bazel with Apache License 2.0 | 5 votes |
/** * Parses a constant string TargetPattern, throwing IllegalStateException on invalid pattern. */ @CheckReturnValue public TargetPattern parseConstantUnchecked(@CompileTimeConstant String pattern) { try { return parse(pattern); } catch (TargetParsingException e) { throw new IllegalStateException(e); } }
Example #9
Source File: FluentEqualityConfig.java From curiostack with MIT License | 4 votes |
@CheckReturnValue abstract Function<? super Optional<Descriptor>, String> usingCorrespondenceStringFunction();
Example #10
Source File: UnicodeEscapePreprocessor.java From turbine with Apache License 2.0 | 4 votes |
@CheckReturnValue private TurbineError error(ErrorKind kind, Object... args) { throw TurbineError.format( source(), Math.min(position(), source().source().length() - 1), kind, args); }
Example #11
Source File: ConstExpressionParser.java From turbine with Apache License 2.0 | 4 votes |
@CheckReturnValue private TurbineError error(ErrorKind kind, Object... args) { return TurbineError.format(lexer.source(), lexer.position(), kind, args); }
Example #12
Source File: Starlark.java From bazel with Apache License 2.0 | 4 votes |
/** * Returns a new EvalException with no location and an error message produced by Java-style string * formatting ({@code String.format(format, args)}). Use {@code errorf("%s", msg)} to produce an * error message from a non-constant expression {@code msg}. */ @FormatMethod @CheckReturnValue // don't forget to throw it public static EvalException errorf(String format, Object... args) { return new EvalException(null, String.format(format, args)); }
Example #13
Source File: CacheBuilder.java From bazel-buildfarm with Apache License 2.0 | 3 votes |
/** * Specifies a listener instance that caches should notify each time an entry is removed for any * {@linkplain RemovalCause reason}. Each cache created by this builder will invoke this listener * as part of the routine maintenance described in the class documentation above. * * <p><b>Warning:</b> after invoking this method, do not continue to use <i>this</i> cache builder * reference; instead use the reference this method <i>returns</i>. At runtime, these point to the * same instance, but only the returned reference has the correct generic type information so as * to ensure type safety. For best results, use the standard method-chaining idiom illustrated in * the class documentation above, configuring a builder and building your cache in a single * statement. Failure to heed this advice can result in a {@link ClassCastException} being thrown * by a cache operation at some <i>undefined</i> point in the future. * * <p><b>Warning:</b> any exception thrown by {@code listener} will <i>not</i> be propagated to * the {@code Cache} user, only logged via a {@link Logger}. * * @return the cache builder reference that should be used instead of {@code this} for any * remaining configuration and cache building * @return this {@code CacheBuilder} instance (for chaining) * @throws IllegalStateException if a removal listener was already set */ @CheckReturnValue public <K1 extends K, V1 extends V> CacheBuilder<K1, V1> removalListener( RemovalListener<? super K1, ? super V1> listener) { checkState(this.removalListener == null); // safely limiting the kinds of caches this can produce @SuppressWarnings("unchecked") CacheBuilder<K1, V1> me = (CacheBuilder<K1, V1>) this; me.removalListener = checkNotNull(listener); return me; }