The following issues were found
python/google/protobuf/service.py
60 issues
Line: 61
Column: 3
its exact type at compile time (analogous to the Message interface).
"""
def GetDescriptor():
"""Retrieves this service's descriptor."""
raise NotImplementedError
def CallMethod(self, method_descriptor, rpc_controller,
request, done):
Reported by Pylint.
Line: 48
Column: 3
class RpcException(Exception):
"""Exception raised on failed blocking RPC method call."""
pass
class Service(object):
"""Abstract base interface for protocol-buffer-based RPC services.
Reported by Pylint.
Line: 47
Column: 1
class RpcException(Exception):
"""Exception raised on failed blocking RPC method call."""
pass
class Service(object):
Reported by Pylint.
Line: 48
Column: 1
class RpcException(Exception):
"""Exception raised on failed blocking RPC method call."""
pass
class Service(object):
"""Abstract base interface for protocol-buffer-based RPC services.
Reported by Pylint.
Line: 51
Column: 1
pass
class Service(object):
"""Abstract base interface for protocol-buffer-based RPC services.
Services themselves are abstract classes (implemented either by servers or as
stubs), but they subclass this base interface. The methods of this
Reported by Pylint.
Line: 53
Column: 1
class Service(object):
"""Abstract base interface for protocol-buffer-based RPC services.
Services themselves are abstract classes (implemented either by servers or as
stubs), but they subclass this base interface. The methods of this
interface can be used to call the methods of the service without knowing
its exact type at compile time (analogous to the Message interface).
Reported by Pylint.
Line: 61
Column: 1
its exact type at compile time (analogous to the Message interface).
"""
def GetDescriptor():
"""Retrieves this service's descriptor."""
raise NotImplementedError
def CallMethod(self, method_descriptor, rpc_controller,
request, done):
Reported by Pylint.
Line: 61
Column: 3
its exact type at compile time (analogous to the Message interface).
"""
def GetDescriptor():
"""Retrieves this service's descriptor."""
raise NotImplementedError
def CallMethod(self, method_descriptor, rpc_controller,
request, done):
Reported by Pylint.
Line: 62
Column: 1
"""
def GetDescriptor():
"""Retrieves this service's descriptor."""
raise NotImplementedError
def CallMethod(self, method_descriptor, rpc_controller,
request, done):
"""Calls a method of the service specified by method_descriptor.
Reported by Pylint.
Line: 63
Column: 1
def GetDescriptor():
"""Retrieves this service's descriptor."""
raise NotImplementedError
def CallMethod(self, method_descriptor, rpc_controller,
request, done):
"""Calls a method of the service specified by method_descriptor.
Reported by Pylint.
ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java
60 issues
Line: 149
* was just inserted.
*/
@JRubyMethod(name = "[]=")
public IRubyObject indexSet(ThreadContext context, IRubyObject key, IRubyObject value) {
checkFrozen();
/*
* String types for keys return a different error than
* other types for keys, so deal with them specifically first
Reported by PMD.
Line: 149
* was just inserted.
*/
@JRubyMethod(name = "[]=")
public IRubyObject indexSet(ThreadContext context, IRubyObject key, IRubyObject value) {
checkFrozen();
/*
* String types for keys return a different error than
* other types for keys, so deal with them specifically first
Reported by PMD.
Line: 149
* was just inserted.
*/
@JRubyMethod(name = "[]=")
public IRubyObject indexSet(ThreadContext context, IRubyObject key, IRubyObject value) {
checkFrozen();
/*
* String types for keys return a different error than
* other types for keys, so deal with them specifically first
Reported by PMD.
Line: 179
* incorrect. Returns nil when the key is not present in the map.
*/
@JRubyMethod(name = "[]")
public IRubyObject index(ThreadContext context, IRubyObject key) {
key = Utils.symToString(key);
return Helpers.nullToNil(table.get(key), context.nil);
}
/*
Reported by PMD.
Line: 404
if (hashmap instanceof RubyHash) {
((RubyHash) hashmap).visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject key, IRubyObject val) {
if (val instanceof RubyHash && !valueTypeClass.isNil()) {
val = ((RubyClass) valueTypeClass).newInstance(context, val, Block.NULL_BLOCK);
}
indexSet(context, key, val);
}
Reported by PMD.
Line: 56
import java.util.Map;
@JRubyClass(name = "Map", include = "Enumerable")
public class RubyMap extends RubyObject {
public static void createRubyMap(Ruby runtime) {
RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
RubyClass cMap = protobuf.defineClassUnder("Map", runtime.getObject(), new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
Reported by PMD.
Line: 104
* message type.
*/
@JRubyMethod(required = 2, optional = 2)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
this.table = new HashMap<IRubyObject, IRubyObject>();
this.keyType = Utils.rubyToFieldType(args[0]);
this.valueType = Utils.rubyToFieldType(args[1]);
switch(keyType) {
Reported by PMD.
Line: 122
// These are OK.
break;
default:
throw context.runtime.newArgumentError("Invalid key type for map.");
}
int initValueArg = 2;
if (needTypeclass(this.valueType) && args.length > 2) {
this.valueTypeClass = args[2];
Reported by PMD.
Line: 131
Utils.validateTypeClass(context, this.valueType, this.valueTypeClass);
initValueArg = 3;
} else {
this.valueTypeClass = context.runtime.getNilClass();
}
if (args.length > initValueArg) {
mergeIntoSelf(context, args[initValueArg]);
}
Reported by PMD.
Line: 157
* other types for keys, so deal with them specifically first
*/
if (keyTypeIsString && !(key instanceof RubySymbol || key instanceof RubyString)) {
throw context.runtime.newTypeError("Expected string for map key");
}
key = Utils.checkType(context, keyType, "key", key, (RubyModule) valueTypeClass);
value = Utils.checkType(context, valueType, "value", value, (RubyModule) valueTypeClass);
IRubyObject symbol;
if (valueType == FieldDescriptor.Type.ENUM &&
Reported by PMD.
java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
60 issues
Line: 43
import java.util.TreeSet;
/** Helps generate {@link String} representations of {@link MessageLite} protos. */
final class MessageLiteToString {
private static final String LIST_SUFFIX = "List";
private static final String BUILDER_LIST_SUFFIX = "OrBuilderList";
private static final String MAP_SUFFIX = "Map";
private static final String BYTES_SUFFIX = "Bytes";
Reported by PMD.
Line: 43
import java.util.TreeSet;
/** Helps generate {@link String} representations of {@link MessageLite} protos. */
final class MessageLiteToString {
private static final String LIST_SUFFIX = "List";
private static final String BUILDER_LIST_SUFFIX = "OrBuilderList";
private static final String MAP_SUFFIX = "Map";
private static final String BYTES_SUFFIX = "Bytes";
Reported by PMD.
Line: 43
import java.util.TreeSet;
/** Helps generate {@link String} representations of {@link MessageLite} protos. */
final class MessageLiteToString {
private static final String LIST_SUFFIX = "List";
private static final String BUILDER_LIST_SUFFIX = "OrBuilderList";
private static final String MAP_SUFFIX = "Map";
private static final String BYTES_SUFFIX = "Bytes";
Reported by PMD.
Line: 43
import java.util.TreeSet;
/** Helps generate {@link String} representations of {@link MessageLite} protos. */
final class MessageLiteToString {
private static final String LIST_SUFFIX = "List";
private static final String BUILDER_LIST_SUFFIX = "OrBuilderList";
private static final String MAP_SUFFIX = "Map";
private static final String BYTES_SUFFIX = "Bytes";
Reported by PMD.
Line: 71
* @param buffer the buffer to write to
* @param indent the number of spaces to indent the proto by
*/
private static void reflectivePrintWithIndent(
MessageLite messageLite, StringBuilder buffer, int indent) {
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
// getFooList() and getFooMap() which might be useful for building an object's string
// representation.
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Reported by PMD.
Line: 71
* @param buffer the buffer to write to
* @param indent the number of spaces to indent the proto by
*/
private static void reflectivePrintWithIndent(
MessageLite messageLite, StringBuilder buffer, int indent) {
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
// getFooList() and getFooMap() which might be useful for building an object's string
// representation.
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Reported by PMD.
Line: 71
* @param buffer the buffer to write to
* @param indent the number of spaces to indent the proto by
*/
private static void reflectivePrintWithIndent(
MessageLite messageLite, StringBuilder buffer, int indent) {
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
// getFooList() and getFooMap() which might be useful for building an object's string
// representation.
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Reported by PMD.
Line: 71
* @param buffer the buffer to write to
* @param indent the number of spaces to indent the proto by
*/
private static void reflectivePrintWithIndent(
MessageLite messageLite, StringBuilder buffer, int indent) {
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
// getFooList() and getFooMap() which might be useful for building an object's string
// representation.
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Reported by PMD.
Line: 71
* @param buffer the buffer to write to
* @param indent the number of spaces to indent the proto by
*/
private static void reflectivePrintWithIndent(
MessageLite messageLite, StringBuilder buffer, int indent) {
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
// getFooList() and getFooMap() which might be useful for building an object's string
// representation.
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Reported by PMD.
Line: 79
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
Map<String, Method> nameToMethod = new HashMap<String, Method>();
Set<String> getters = new TreeSet<String>();
for (Method method : messageLite.getClass().getDeclaredMethods()) {
nameToMethod.put(method.getName(), method);
if (method.getParameterTypes().length == 0) {
nameToNoArgMethod.put(method.getName(), method);
if (method.getName().startsWith("get")) {
Reported by PMD.
python/google/protobuf/internal/api_implementation.py
59 issues
Line: 39
Column: 1
import warnings
try:
# pylint: disable=g-import-not-at-top
from google.protobuf.internal import _api_implementation
# The compile-time constants in the _api_implementation module can be used to
# switch to a certain implementation of the Python API at build time.
_api_version = _api_implementation.api_version
_proto_extension_modules_exist_in_build = True
Reported by Pylint.
Line: 56
Column: 1
# The presence of this module in a build allows the proto implementation to
# be upgraded merely via build deps rather than a compiler flag or the
# runtime environment variable.
# pylint: disable=g-import-not-at-top
from google.protobuf import _use_fast_cpp_protos
# Work around a known issue in the classic bootstrap .par import hook.
if not _use_fast_cpp_protos:
raise ImportError('_use_fast_cpp_protos import succeeded but was None')
del _use_fast_cpp_protos
Reported by Pylint.
Line: 70
Column: 1
'This should be impossible via a link error at build time...')
except ImportError:
try:
# pylint: disable=g-import-not-at-top
from google.protobuf import use_pure_python
del use_pure_python # Avoids a pylint error and namespace pollution.
_api_version = 0
except ImportError:
# TODO(b/74017912): It's unsafe to enable :use_fast_cpp_protos by default;
Reported by Pylint.
Line: 130
Column: 1
# use by this module. That is intended behavior, so we don't actually expose
# this boolean outside of this module.
#
# pylint: disable=g-import-not-at-top,unused-import
from google.protobuf import enable_deterministic_proto_serialization
_python_deterministic_proto_serialization = True
except ImportError:
_python_deterministic_proto_serialization = False
Reported by Pylint.
Line: 75
Column: 3
del use_pure_python # Avoids a pylint error and namespace pollution.
_api_version = 0
except ImportError:
# TODO(b/74017912): It's unsafe to enable :use_fast_cpp_protos by default;
# it can cause data loss if you have any Python-only extensions to any
# message passed back and forth with C++ code.
#
# TODO(b/17427486): Once that bug is fixed, we want to make both Python 2
# and Python 3 default to `_api_version = 2` (C++ implementation V2).
Reported by Pylint.
Line: 79
Column: 3
# it can cause data loss if you have any Python-only extensions to any
# message passed back and forth with C++ code.
#
# TODO(b/17427486): Once that bug is fixed, we want to make both Python 2
# and Python 3 default to `_api_version = 2` (C++ implementation V2).
pass
_default_implementation_type = ('python' if _api_version <= 0 else 'cpp')
Reported by Pylint.
Line: 147
Column: 3
def _SetType(implementation_type):
"""Never use! Only for protobuf benchmark."""
global _implementation_type
_implementation_type = implementation_type
# See comment on 'Type' above.
def Version():
Reported by Pylint.
Line: 40
Column: 1
try:
# pylint: disable=g-import-not-at-top
from google.protobuf.internal import _api_implementation
# The compile-time constants in the _api_implementation module can be used to
# switch to a certain implementation of the Python API at build time.
_api_version = _api_implementation.api_version
_proto_extension_modules_exist_in_build = True
except ImportError:
Reported by Pylint.
Line: 43
Column: 1
from google.protobuf.internal import _api_implementation
# The compile-time constants in the _api_implementation module can be used to
# switch to a certain implementation of the Python API at build time.
_api_version = _api_implementation.api_version
_proto_extension_modules_exist_in_build = True
except ImportError:
_api_version = -1 # Unspecified by compiler flags.
_proto_extension_modules_exist_in_build = False
Reported by Pylint.
Line: 44
Column: 3
# The compile-time constants in the _api_implementation module can be used to
# switch to a certain implementation of the Python API at build time.
_api_version = _api_implementation.api_version
_proto_extension_modules_exist_in_build = True
except ImportError:
_api_version = -1 # Unspecified by compiler flags.
_proto_extension_modules_exist_in_build = False
if _api_version == 1:
Reported by Pylint.
java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
59 issues
Line: 460
}
/** equals() that handles null values. */
private boolean equals(Object o1, Object o2) {
return o1 == null ? o2 == null : o1.equals(o2);
}
}
/** Stateless view of the entries in the field map. */
Reported by PMD.
Line: 83
// This class is final for all intents and purposes because the constructor is
// private. However, the FieldDescriptor-specific logic is encapsulated in
// a subclass to aid testability of the core logic.
class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
/**
* Creates a new instance for mapping FieldDescriptors to their values. The {@link
* #makeImmutable()} implementation will convert the List values of any repeated fields to
* unmodifiable lists.
Reported by PMD.
Line: 97
SmallSortedMap<FieldDescriptorType, Object> newFieldMap(int arraySize) {
return new SmallSortedMap<FieldDescriptorType, Object>(arraySize) {
@Override
@SuppressWarnings("unchecked")
public void makeImmutable() {
if (!isImmutable()) {
for (int i = 0; i < getNumArrayEntries(); i++) {
final Map.Entry<FieldDescriptorType, Object> entry = getArrayEntryAt(i);
if (entry.getKey().isRepeated()) {
Reported by PMD.
Line: 102
if (!isImmutable()) {
for (int i = 0; i < getNumArrayEntries(); i++) {
final Map.Entry<FieldDescriptorType, Object> entry = getArrayEntryAt(i);
if (entry.getKey().isRepeated()) {
final List value = (List) entry.getValue();
entry.setValue(Collections.unmodifiableList(value));
}
}
for (Map.Entry<FieldDescriptorType, Object> entry : getOverflowEntries()) {
Reported by PMD.
Line: 108
}
}
for (Map.Entry<FieldDescriptorType, Object> entry : getOverflowEntries()) {
if (entry.getKey().isRepeated()) {
final List value = (List) entry.getValue();
entry.setValue(Collections.unmodifiableList(value));
}
}
}
Reported by PMD.
Line: 129
return new SmallSortedMap<K, V>(arraySize);
}
private final int maxArraySize;
// The "entry array" is actually a List because generic arrays are not
// allowed. ArrayList also nicely handles the entry shifting on inserts and
// removes.
private List<Entry> entryList;
private Map<K, V> overflowEntries;
Reported by PMD.
Line: 133
// The "entry array" is actually a List because generic arrays are not
// allowed. ArrayList also nicely handles the entry shifting on inserts and
// removes.
private List<Entry> entryList;
private Map<K, V> overflowEntries;
private boolean isImmutable;
// The EntrySet is a stateless view of the Map. It's initialized the first
// time it is requested and reused henceforth.
private volatile EntrySet lazyEntrySet;
Reported by PMD.
Line: 134
// allowed. ArrayList also nicely handles the entry shifting on inserts and
// removes.
private List<Entry> entryList;
private Map<K, V> overflowEntries;
private boolean isImmutable;
// The EntrySet is a stateless view of the Map. It's initialized the first
// time it is requested and reused henceforth.
private volatile EntrySet lazyEntrySet;
private Map<K, V> overflowEntriesDescending;
Reported by PMD.
Line: 135
// removes.
private List<Entry> entryList;
private Map<K, V> overflowEntries;
private boolean isImmutable;
// The EntrySet is a stateless view of the Map. It's initialized the first
// time it is requested and reused henceforth.
private volatile EntrySet lazyEntrySet;
private Map<K, V> overflowEntriesDescending;
private volatile DescendingEntrySet lazyDescendingEntrySet;
Reported by PMD.
Line: 135
// removes.
private List<Entry> entryList;
private Map<K, V> overflowEntries;
private boolean isImmutable;
// The EntrySet is a stateless view of the Map. It's initialized the first
// time it is requested and reused henceforth.
private volatile EntrySet lazyEntrySet;
private Map<K, V> overflowEntriesDescending;
private volatile DescendingEntrySet lazyDescendingEntrySet;
Reported by PMD.
java/core/src/test/java/com/google/protobuf/Utf8Test.java
58 issues
Line: 43
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class Utf8Test {
private static final int NUM_CHARS = 16384;
private static final Utf8.Processor safeProcessor = new Utf8.SafeProcessor();
private static final Utf8.Processor unsafeProcessor = new Utf8.UnsafeProcessor();
Reported by PMD.
Line: 50
private static final Utf8.Processor unsafeProcessor = new Utf8.UnsafeProcessor();
@Test
public void testEncode() {
assertEncoding(randomString(0x80));
assertEncoding(randomString(0x90));
assertEncoding(randomString(0x800));
assertEncoding(randomString(0x10000));
assertEncoding(randomString(0x10ffff));
Reported by PMD.
Line: 59
}
@Test
public void testEncode_insufficientSpace() {
assertEncoding_insufficientSpace(randomString(0x80));
assertEncoding_insufficientSpace(randomString(0x90));
assertEncoding_insufficientSpace(randomString(0x800));
assertEncoding_insufficientSpace(randomString(0x10000));
assertEncoding_insufficientSpace(randomString(0x10ffff));
Reported by PMD.
Line: 68
}
@Test
public void testValid() {
assertIsValid(new byte[] {(byte) 0xE0, (byte) 0xB9, (byte) 0x96}, true);
assertIsValid(new byte[] {(byte) 0xF0, (byte) 0xB2, (byte) 0x83, (byte) 0xBC}, true);
}
@Test
Reported by PMD.
Line: 74
}
@Test
public void testOverlongIsInvalid() {
assertIsValid(new byte[] {(byte) 0xC0, (byte) 0x81}, false);
assertIsValid(new byte[] {(byte) 0xE0, (byte) 0x81, (byte) 0x81}, false);
assertIsValid(new byte[] {(byte) 0xF0, (byte) 0x81, (byte) 0x81, (byte) 0x81}, false);
}
Reported by PMD.
Line: 87
}
@Test
public void testInvalidSurrogateCodepoint() {
assertIsValid(new byte[] {(byte) 0xED, (byte) 0xA1, (byte) 0x81}, false);
// byte1 == 0xF0 && byte2 < 0x90
assertIsValid(new byte[] {(byte) 0xF0, (byte) 0x81, (byte) 0x81, (byte) 0x81}, false);
// byte1 == 0xF4 && byte2 > 0x8F
Reported by PMD.
Line: 111
}
private static void assertIsValid(byte[] data, boolean valid) {
assertWithMessage("isValidUtf8[ARRAY]")
.that(safeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
assertWithMessage("isValidUtf8[ARRAY_UNSAFE]")
.that(unsafeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
Reported by PMD.
Line: 111
}
private static void assertIsValid(byte[] data, boolean valid) {
assertWithMessage("isValidUtf8[ARRAY]")
.that(safeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
assertWithMessage("isValidUtf8[ARRAY_UNSAFE]")
.that(unsafeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
Reported by PMD.
Line: 114
assertWithMessage("isValidUtf8[ARRAY]")
.that(safeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
assertWithMessage("isValidUtf8[ARRAY_UNSAFE]")
.that(unsafeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
ByteBuffer buffer = ByteBuffer.wrap(data);
assertWithMessage("isValidUtf8[NIO_HEAP]")
Reported by PMD.
Line: 114
assertWithMessage("isValidUtf8[ARRAY]")
.that(safeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
assertWithMessage("isValidUtf8[ARRAY_UNSAFE]")
.that(unsafeProcessor.isValidUtf8(data, 0, data.length))
.isEqualTo(valid);
ByteBuffer buffer = ByteBuffer.wrap(data);
assertWithMessage("isValidUtf8[NIO_HEAP]")
Reported by PMD.
benchmarks/util/result_uploader.py
58 issues
Line: 12
Column: 1
import time
import datetime
from util import big_query_utils
from util import result_parser
_PROJECT_ID = 'grpc-testing'
_DATASET = 'protobuf_benchmark_result'
_TABLE = 'opensource_result_v2'
Reported by Pylint.
Line: 13
Column: 1
import datetime
from util import big_query_utils
from util import result_parser
_PROJECT_ID = 'grpc-testing'
_DATASET = 'protobuf_benchmark_result'
_TABLE = 'opensource_result_v2'
_NOW = "%d%02d%02d" % (datetime.datetime.now().year,
Reported by Pylint.
Line: 5
Column: 1
from __future__ import absolute_import
import argparse
import os
import re
import copy
import uuid
import calendar
import time
import datetime
Reported by Pylint.
Line: 6
Column: 1
import argparse
import os
import re
import copy
import uuid
import calendar
import time
import datetime
Reported by Pylint.
Line: 33
Column: 3
git_actual_commit = os.getenv('ghprbActualCommit')
utc_timestamp = str(calendar.timegm(time.gmtime()))
metadata = {'created': utc_timestamp}
if build_number:
metadata['buildNumber'] = build_number
if build_url:
metadata['buildUrl'] = build_url
Reported by Pylint.
Line: 49
Column: 32
return metadata
def upload_result(result_list, metadata):
for result in result_list:
new_result = {}
new_result["metric"] = "throughput"
new_result["value"] = result["throughput"]
new_result["unit"] = "MB/s"
Reported by Pylint.
Line: 49
Column: 32
return metadata
def upload_result(result_list, metadata):
for result in result_list:
new_result = {}
new_result["metric"] = "throughput"
new_result["value"] = result["throughput"]
new_result["unit"] = "MB/s"
Reported by Pylint.
Line: 1
Column: 1
from __future__ import print_function
from __future__ import absolute_import
import argparse
import os
import re
import copy
import uuid
import calendar
import time
Reported by Pylint.
Line: 24
Column: 1
_INITIAL_TIME = calendar.timegm(time.gmtime())
def get_metadata():
build_number = os.getenv('BUILD_NUMBER')
build_url = os.getenv('BUILD_URL')
job_name = os.getenv('JOB_NAME')
git_commit = os.getenv('GIT_COMMIT')
# actual commit is the actual head of PR that is getting tested
Reported by Pylint.
Line: 25
Column: 1
_INITIAL_TIME = calendar.timegm(time.gmtime())
def get_metadata():
build_number = os.getenv('BUILD_NUMBER')
build_url = os.getenv('BUILD_URL')
job_name = os.getenv('JOB_NAME')
git_commit = os.getenv('GIT_COMMIT')
# actual commit is the actual head of PR that is getting tested
git_actual_commit = os.getenv('ghprbActualCommit')
Reported by Pylint.
python/stubout.py
57 issues
Line: 1
Column: 1
#!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
Reported by Pylint.
Line: 24
Column: 1
class StubOutForTesting:
"""Sample Usage:
You want os.path.exists() to always return true during testing.
stubs = StubOutForTesting()
stubs.Set(os.path, 'exists', lambda x: 1)
...
Reported by Pylint.
Line: 37
Column: 1
of os.path.exists and restores it.
"""
def __init__(self):
self.cache = []
self.stubs = []
def __del__(self):
self.SmartUnsetAll()
Reported by Pylint.
Line: 38
Column: 1
"""
def __init__(self):
self.cache = []
self.stubs = []
def __del__(self):
self.SmartUnsetAll()
self.UnsetAll()
Reported by Pylint.
Line: 39
Column: 1
"""
def __init__(self):
self.cache = []
self.stubs = []
def __del__(self):
self.SmartUnsetAll()
self.UnsetAll()
Reported by Pylint.
Line: 41
Column: 1
self.cache = []
self.stubs = []
def __del__(self):
self.SmartUnsetAll()
self.UnsetAll()
def SmartSet(self, obj, attr_name, new_attr):
"""Replace obj.attr_name with new_attr. This method is smart and works
Reported by Pylint.
Line: 42
Column: 1
self.stubs = []
def __del__(self):
self.SmartUnsetAll()
self.UnsetAll()
def SmartSet(self, obj, attr_name, new_attr):
"""Replace obj.attr_name with new_attr. This method is smart and works
at the module, class, and instance level while preserving proper
Reported by Pylint.
Line: 43
Column: 1
def __del__(self):
self.SmartUnsetAll()
self.UnsetAll()
def SmartSet(self, obj, attr_name, new_attr):
"""Replace obj.attr_name with new_attr. This method is smart and works
at the module, class, and instance level while preserving proper
inheritance. It will not stub out C types however unless that has been
Reported by Pylint.
Line: 45
Column: 3
self.SmartUnsetAll()
self.UnsetAll()
def SmartSet(self, obj, attr_name, new_attr):
"""Replace obj.attr_name with new_attr. This method is smart and works
at the module, class, and instance level while preserving proper
inheritance. It will not stub out C types however unless that has been
explicitly allowed by the type.
Reported by Pylint.
Line: 45
Column: 1
self.SmartUnsetAll()
self.UnsetAll()
def SmartSet(self, obj, attr_name, new_attr):
"""Replace obj.attr_name with new_attr. This method is smart and works
at the module, class, and instance level while preserving proper
inheritance. It will not stub out C types however unless that has been
explicitly allowed by the type.
Reported by Pylint.
python/google/protobuf/symbol_database.py
56 issues
Line: 151
Column: 3
return self._classes[self.pool.FindMessageTypeByName(symbol)]
def GetMessages(self, files):
# TODO(amauryfa): Fix the differences with MessageFactory.
"""Gets all registered messages from a specified file.
Only messages already created and registered will be returned; (this is the
case for imported _pb2 modules)
But unlike MessageFactory, this version also returns already defined nested
Reported by Pylint.
Line: 67
Column: 1
class SymbolDatabase(message_factory.MessageFactory):
"""A database of Python generated symbols."""
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
Calls to GetSymbol() and GetMessages() will return messages registered here.
Reported by Pylint.
Line: 69
Column: 1
class SymbolDatabase(message_factory.MessageFactory):
"""A database of Python generated symbols."""
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
Calls to GetSymbol() and GetMessages() will return messages registered here.
Args:
Reported by Pylint.
Line: 69
Column: 3
class SymbolDatabase(message_factory.MessageFactory):
"""A database of Python generated symbols."""
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
Calls to GetSymbol() and GetMessages() will return messages registered here.
Args:
Reported by Pylint.
Line: 70
Column: 1
"""A database of Python generated symbols."""
def RegisterMessage(self, message):
"""Registers the given message type in the local database.
Calls to GetSymbol() and GetMessages() will return messages registered here.
Args:
message: A :class:`google.protobuf.message.Message` subclass (or
Reported by Pylint.
Line: 82
Column: 1
The provided message.
"""
desc = message.DESCRIPTOR
self._classes[desc] = message
self.RegisterMessageDescriptor(desc)
return message
def RegisterMessageDescriptor(self, message_descriptor):
Reported by Pylint.
Line: 83
Column: 1
"""
desc = message.DESCRIPTOR
self._classes[desc] = message
self.RegisterMessageDescriptor(desc)
return message
def RegisterMessageDescriptor(self, message_descriptor):
"""Registers the given message descriptor in the local database.
Reported by Pylint.
Line: 84
Column: 1
desc = message.DESCRIPTOR
self._classes[desc] = message
self.RegisterMessageDescriptor(desc)
return message
def RegisterMessageDescriptor(self, message_descriptor):
"""Registers the given message descriptor in the local database.
Reported by Pylint.
Line: 85
Column: 1
desc = message.DESCRIPTOR
self._classes[desc] = message
self.RegisterMessageDescriptor(desc)
return message
def RegisterMessageDescriptor(self, message_descriptor):
"""Registers the given message descriptor in the local database.
Args:
Reported by Pylint.
Line: 87
Column: 3
self.RegisterMessageDescriptor(desc)
return message
def RegisterMessageDescriptor(self, message_descriptor):
"""Registers the given message descriptor in the local database.
Args:
message_descriptor (Descriptor): the message descriptor to add.
"""
Reported by Pylint.
java/core/src/test/java/com/google/protobuf/TestBadIdentifiersLite.java
55 issues
Line: 48
*/
public final class TestBadIdentifiersLite extends TestCase {
public void testCompilation() {
// If this compiles, it means the generation was correct.
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
Reported by PMD.
Line: 48
*/
public final class TestBadIdentifiersLite extends TestCase {
public void testCompilation() {
// If this compiles, it means the generation was correct.
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
Reported by PMD.
Line: 50
public void testCompilation() {
// If this compiles, it means the generation was correct.
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
}
Reported by PMD.
Line: 51
public void testCompilation() {
// If this compiles, it means the generation was correct.
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
}
public void testConflictingFieldNames() throws Exception {
Reported by PMD.
Line: 52
// If this compiles, it means the generation was correct.
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
}
public void testConflictingFieldNames() throws Exception {
TestBadIdentifiersProto.TestConflictingFieldNames message =
Reported by PMD.
Line: 53
TestBadIdentifiersProto.Deprecated.Builder builder1 =
TestBadIdentifiersProto.Deprecated.newBuilder();
TestBadIdentifiersProto.Override.Builder builder2 =
TestBadIdentifiersProto.Override.newBuilder();
}
public void testConflictingFieldNames() throws Exception {
TestBadIdentifiersProto.TestConflictingFieldNames message =
TestBadIdentifiersProto.TestConflictingFieldNames.getDefaultInstance();
Reported by PMD.
Line: 56
TestBadIdentifiersProto.Override.newBuilder();
}
public void testConflictingFieldNames() throws Exception {
TestBadIdentifiersProto.TestConflictingFieldNames message =
TestBadIdentifiersProto.TestConflictingFieldNames.getDefaultInstance();
// Make sure generated accessors are properly named.
assertThat(message.getInt32Field1Count()).isEqualTo(0);
assertThat(message.getEnumField2Count()).isEqualTo(0);
Reported by PMD.
Line: 56
TestBadIdentifiersProto.Override.newBuilder();
}
public void testConflictingFieldNames() throws Exception {
TestBadIdentifiersProto.TestConflictingFieldNames message =
TestBadIdentifiersProto.TestConflictingFieldNames.getDefaultInstance();
// Make sure generated accessors are properly named.
assertThat(message.getInt32Field1Count()).isEqualTo(0);
assertThat(message.getEnumField2Count()).isEqualTo(0);
Reported by PMD.
Line: 58
public void testConflictingFieldNames() throws Exception {
TestBadIdentifiersProto.TestConflictingFieldNames message =
TestBadIdentifiersProto.TestConflictingFieldNames.getDefaultInstance();
// Make sure generated accessors are properly named.
assertThat(message.getInt32Field1Count()).isEqualTo(0);
assertThat(message.getEnumField2Count()).isEqualTo(0);
assertThat(message.getStringField3Count()).isEqualTo(0);
assertThat(message.getBytesField4Count()).isEqualTo(0);
Reported by PMD.
Line: 60
TestBadIdentifiersProto.TestConflictingFieldNames message =
TestBadIdentifiersProto.TestConflictingFieldNames.getDefaultInstance();
// Make sure generated accessors are properly named.
assertThat(message.getInt32Field1Count()).isEqualTo(0);
assertThat(message.getEnumField2Count()).isEqualTo(0);
assertThat(message.getStringField3Count()).isEqualTo(0);
assertThat(message.getBytesField4Count()).isEqualTo(0);
assertThat(message.getMessageField5Count()).isEqualTo(0);
Reported by PMD.