The following issues were found
java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java
136 issues
Line: 247
private void assertImmutable(List<Integer> list) {
if (list.contains(1)) {
throw new RuntimeException("Cannot test the immutability of lists that contain 1.");
}
try {
list.add(1);
fail();
Reported by PMD.
Line: 42
import junit.framework.TestCase;
/** Tests for {@link ProtobufArrayList}. */
public class ProtobufArrayListTest extends TestCase {
private static final ProtobufArrayList<Integer> UNARY_LIST = newImmutableProtoArrayList(1);
private static final ProtobufArrayList<Integer> TERTIARY_LIST =
newImmutableProtoArrayList(1, 2, 3);
Reported by PMD.
Line: 42
import junit.framework.TestCase;
/** Tests for {@link ProtobufArrayList}. */
public class ProtobufArrayListTest extends TestCase {
private static final ProtobufArrayList<Integer> UNARY_LIST = newImmutableProtoArrayList(1);
private static final ProtobufArrayList<Integer> TERTIARY_LIST =
newImmutableProtoArrayList(1, 2, 3);
Reported by PMD.
Line: 42
import junit.framework.TestCase;
/** Tests for {@link ProtobufArrayList}. */
public class ProtobufArrayListTest extends TestCase {
private static final ProtobufArrayList<Integer> UNARY_LIST = newImmutableProtoArrayList(1);
private static final ProtobufArrayList<Integer> TERTIARY_LIST =
newImmutableProtoArrayList(1, 2, 3);
Reported by PMD.
Line: 48
private static final ProtobufArrayList<Integer> TERTIARY_LIST =
newImmutableProtoArrayList(1, 2, 3);
private ProtobufArrayList<Integer> list;
@Override
protected void setUp() throws Exception {
list = new ProtobufArrayList<Integer>();
}
Reported by PMD.
Line: 50
private ProtobufArrayList<Integer> list;
@Override
protected void setUp() throws Exception {
list = new ProtobufArrayList<Integer>();
}
public void testEmptyListReturnsSameInstance() {
Reported by PMD.
Line: 55
list = new ProtobufArrayList<Integer>();
}
public void testEmptyListReturnsSameInstance() {
assertSame(ProtobufArrayList.emptyList(), ProtobufArrayList.emptyList());
}
public void testEmptyListIsImmutable() {
assertImmutable(ProtobufArrayList.<Integer>emptyList());
Reported by PMD.
Line: 56
}
public void testEmptyListReturnsSameInstance() {
assertSame(ProtobufArrayList.emptyList(), ProtobufArrayList.emptyList());
}
public void testEmptyListIsImmutable() {
assertImmutable(ProtobufArrayList.<Integer>emptyList());
}
Reported by PMD.
Line: 59
assertSame(ProtobufArrayList.emptyList(), ProtobufArrayList.emptyList());
}
public void testEmptyListIsImmutable() {
assertImmutable(ProtobufArrayList.<Integer>emptyList());
}
public void testModificationWithIteration() {
list.addAll(asList(1, 2, 3, 4));
Reported by PMD.
Line: 63
assertImmutable(ProtobufArrayList.<Integer>emptyList());
}
public void testModificationWithIteration() {
list.addAll(asList(1, 2, 3, 4));
Iterator<Integer> iterator = list.iterator();
assertEquals(4, list.size());
assertEquals(1, (int) list.get(0));
assertEquals(1, (int) iterator.next());
Reported by PMD.
java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
129 issues
Line: 48
/** Tests for {@link LazyStringArrayList}. */
@RunWith(JUnit4.class)
public class LazyStringArrayListTest {
private static final String STRING_A = "A";
private static final String STRING_B = "B";
private static final String STRING_C = "C";
Reported by PMD.
Line: 48
/** Tests for {@link LazyStringArrayList}. */
@RunWith(JUnit4.class)
public class LazyStringArrayListTest {
private static final String STRING_A = "A";
private static final String STRING_B = "B";
private static final String STRING_C = "C";
Reported by PMD.
Line: 59
private static final ByteString BYTE_STRING_C = ByteString.copyFromUtf8("C");
@Test
public void testJustStrings() {
LazyStringArrayList list = new LazyStringArrayList();
list.add(STRING_A);
list.add(STRING_B);
list.add(STRING_C);
Reported by PMD.
Line: 65
list.add(STRING_B);
list.add(STRING_C);
assertThat(list).hasSize(3);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_B);
assertThat(list.get(2)).isSameInstanceAs(STRING_C);
list.set(1, STRING_C);
Reported by PMD.
Line: 66
list.add(STRING_C);
assertThat(list).hasSize(3);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_B);
assertThat(list.get(2)).isSameInstanceAs(STRING_C);
list.set(1, STRING_C);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
Reported by PMD.
Line: 67
assertThat(list).hasSize(3);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_B);
assertThat(list.get(2)).isSameInstanceAs(STRING_C);
list.set(1, STRING_C);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
Reported by PMD.
Line: 68
assertThat(list).hasSize(3);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_B);
assertThat(list.get(2)).isSameInstanceAs(STRING_C);
list.set(1, STRING_C);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
list.remove(1);
Reported by PMD.
Line: 71
assertThat(list.get(2)).isSameInstanceAs(STRING_C);
list.set(1, STRING_C);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
list.remove(1);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
Reported by PMD.
Line: 74
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
list.remove(1);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
List<ByteString> byteStringList = list.asByteStringList();
assertThat(byteStringList.get(0)).isEqualTo(BYTE_STRING_A);
assertThat(byteStringList.get(1)).isEqualTo(BYTE_STRING_C);
Reported by PMD.
Line: 75
list.remove(1);
assertThat(list.get(0)).isSameInstanceAs(STRING_A);
assertThat(list.get(1)).isSameInstanceAs(STRING_C);
List<ByteString> byteStringList = list.asByteStringList();
assertThat(byteStringList.get(0)).isEqualTo(BYTE_STRING_A);
assertThat(byteStringList.get(1)).isEqualTo(BYTE_STRING_C);
Reported by PMD.
python/google/protobuf/internal/_parameterized.py
126 issues
Line: 271
Column: 3
assert not getattr(class_object, '_id_suffix', None), (
'Cannot add parameters to %s,'
' which already has parameterized methods.' % (class_object,))
class_object._id_suffix = id_suffix = {}
# We change the size of __dict__ while we iterate over it,
# which Python 3.x will complain about, so use copy().
for name, obj in class_object.__dict__.copy().items():
if (name.startswith(unittest.TestLoader.testMethodPrefix)
and isinstance(obj, types.FunctionType)):
Reported by Pylint.
Line: 282
Column: 7
_UpdateClassDictForParamTestCase(
methods, id_suffix, name,
_ParameterizedTestIter(obj, testcases, naming_type))
for name, meth in methods.items():
setattr(class_object, name, meth)
def _ParameterDecorator(naming_type, testcases):
"""Implementation of the parameterization decorators.
Reported by Pylint.
Line: 152
Column: 1
import re
import types
try:
import unittest2 as unittest
except ImportError:
import unittest
import uuid
import six
Reported by Pylint.
Line: 154
Column: 1
try:
import unittest2 as unittest
except ImportError:
import unittest
import uuid
import six
try:
Reported by Pylint.
Line: 161
Column: 1
try:
# Since python 3
import collections.abc as collections_abc
except ImportError:
# Won't work after python 3.8
import collections as collections_abc
ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>')
Reported by Pylint.
Line: 164
Column: 1
import collections.abc as collections_abc
except ImportError:
# Won't work after python 3.8
import collections as collections_abc
ADDR_RE = re.compile(r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>')
_SEPARATOR = uuid.uuid1().hex
_FIRST_ARG = object()
_ARGUMENT_REPR = object()
Reported by Pylint.
Line: 172
Column: 1
_ARGUMENT_REPR = object()
def _CleanRepr(obj):
return ADDR_RE.sub(r'<\1>', repr(obj))
# Helper function formerly from the unittest module, removed from it in
# Python 2.7.
Reported by Pylint.
Line: 173
Column: 1
def _CleanRepr(obj):
return ADDR_RE.sub(r'<\1>', repr(obj))
# Helper function formerly from the unittest module, removed from it in
# Python 2.7.
def _StrClass(cls):
Reported by Pylint.
Line: 178
Column: 1
# Helper function formerly from the unittest module, removed from it in
# Python 2.7.
def _StrClass(cls):
return '%s.%s' % (cls.__module__, cls.__name__)
def _NonStringIterable(obj):
return (isinstance(obj, collections_abc.Iterable) and not
Reported by Pylint.
Line: 179
Column: 1
# Helper function formerly from the unittest module, removed from it in
# Python 2.7.
def _StrClass(cls):
return '%s.%s' % (cls.__module__, cls.__name__)
def _NonStringIterable(obj):
return (isinstance(obj, collections_abc.Iterable) and not
isinstance(obj, six.string_types))
Reported by Pylint.
python/google/protobuf/internal/wire_format.py
126 issues
Line: 151
Column: 35
return UInt64ByteSize(field_number, ZigZagEncode(int64))
def Fixed32ByteSize(field_number, fixed32):
return TagByteSize(field_number) + 4
def Fixed64ByteSize(field_number, fixed64):
return TagByteSize(field_number) + 8
Reported by Pylint.
Line: 155
Column: 35
return TagByteSize(field_number) + 4
def Fixed64ByteSize(field_number, fixed64):
return TagByteSize(field_number) + 8
def SFixed32ByteSize(field_number, sfixed32):
return TagByteSize(field_number) + 4
Reported by Pylint.
Line: 159
Column: 36
return TagByteSize(field_number) + 8
def SFixed32ByteSize(field_number, sfixed32):
return TagByteSize(field_number) + 4
def SFixed64ByteSize(field_number, sfixed64):
return TagByteSize(field_number) + 8
Reported by Pylint.
Line: 163
Column: 36
return TagByteSize(field_number) + 4
def SFixed64ByteSize(field_number, sfixed64):
return TagByteSize(field_number) + 8
def FloatByteSize(field_number, flt):
return TagByteSize(field_number) + 4
Reported by Pylint.
Line: 167
Column: 33
return TagByteSize(field_number) + 8
def FloatByteSize(field_number, flt):
return TagByteSize(field_number) + 4
def DoubleByteSize(field_number, double):
return TagByteSize(field_number) + 8
Reported by Pylint.
Line: 171
Column: 34
return TagByteSize(field_number) + 4
def DoubleByteSize(field_number, double):
return TagByteSize(field_number) + 8
def BoolByteSize(field_number, b):
return TagByteSize(field_number) + 1
Reported by Pylint.
Line: 175
Column: 32
return TagByteSize(field_number) + 8
def BoolByteSize(field_number, b):
return TagByteSize(field_number) + 1
def EnumByteSize(field_number, enum):
return UInt32ByteSize(field_number, enum)
Reported by Pylint.
Line: 193
Column: 33
+ len(b))
def GroupByteSize(field_number, message):
return (2 * TagByteSize(field_number) # START and END group.
+ message.ByteSize())
def MessageByteSize(field_number, message):
Reported by Pylint.
Line: 198
Column: 35
+ message.ByteSize())
def MessageByteSize(field_number, message):
return (TagByteSize(field_number)
+ _VarUInt64ByteSizeNoTag(message.ByteSize())
+ message.ByteSize())
Reported by Pylint.
Line: 75
Column: 1
# We'll have to provide alternate implementations of AppendLittleEndian*() on
# any architectures where these checks fail.
if struct.calcsize(FORMAT_UINT32_LITTLE_ENDIAN) != 4:
raise AssertionError('Format "I" is not a 32-bit number.')
if struct.calcsize(FORMAT_UINT64_LITTLE_ENDIAN) != 8:
raise AssertionError('Format "Q" is not a 64-bit number.')
def PackTag(field_number, wire_type):
Reported by Pylint.
java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java
123 issues
Line: 1317
case UINT64:
return readUInt64();
default:
throw new RuntimeException("unsupported field type.");
}
}
private void verifyPackedFixed32Length(int bytes) throws IOException {
if ((bytes & FIXED32_MULTIPLE_MASK) != 0) {
Reported by PMD.
Line: 31
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf;
import static com.google.protobuf.WireFormat.FIXED32_SIZE;
import static com.google.protobuf.WireFormat.FIXED64_SIZE;
import static com.google.protobuf.WireFormat.WIRETYPE_END_GROUP;
import static com.google.protobuf.WireFormat.WIRETYPE_FIXED32;
Reported by PMD.
Line: 48
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
@ExperimentalApi
final class CodedInputStreamReader implements Reader {
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
Reported by PMD.
Line: 48
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
@ExperimentalApi
final class CodedInputStreamReader implements Reader {
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
Reported by PMD.
Line: 48
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
@ExperimentalApi
final class CodedInputStreamReader implements Reader {
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
Reported by PMD.
Line: 48
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
@ExperimentalApi
final class CodedInputStreamReader implements Reader {
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
Reported by PMD.
Line: 48
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
@ExperimentalApi
final class CodedInputStreamReader implements Reader {
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
Reported by PMD.
Line: 53
private static final int FIXED64_MULTIPLE_MASK = FIXED64_SIZE - 1;
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
private int tag;
private int endGroupTag;
private int nextTag = NEXT_TAG_UNSET;
public static CodedInputStreamReader forCodedInput(CodedInputStream input) {
Reported by PMD.
Line: 54
private static final int NEXT_TAG_UNSET = 0;
private final CodedInputStream input;
private int tag;
private int endGroupTag;
private int nextTag = NEXT_TAG_UNSET;
public static CodedInputStreamReader forCodedInput(CodedInputStream input) {
if (input.wrapper != null) {
Reported by PMD.
Line: 55
private final CodedInputStream input;
private int tag;
private int endGroupTag;
private int nextTag = NEXT_TAG_UNSET;
public static CodedInputStreamReader forCodedInput(CodedInputStream input) {
if (input.wrapper != null) {
return input.wrapper;
Reported by PMD.
python/google/protobuf/internal/service_reflection_test.py
122 issues
Line: 43
Column: 1
except ImportError:
import unittest
from google.protobuf import unittest_pb2
from google.protobuf import service_reflection
from google.protobuf import service
class FooUnitTest(unittest.TestCase):
Reported by Pylint.
Line: 44
Column: 1
import unittest
from google.protobuf import unittest_pb2
from google.protobuf import service_reflection
from google.protobuf import service
class FooUnitTest(unittest.TestCase):
Reported by Pylint.
Line: 52
Column: 7
def testService(self):
class MockRpcChannel(service.RpcChannel):
def CallMethod(self, method, controller, request, response, callback):
self.method = method
self.controller = controller
self.request = request
callback(response)
Reported by Pylint.
Line: 53
Column: 9
def testService(self):
class MockRpcChannel(service.RpcChannel):
def CallMethod(self, method, controller, request, response, callback):
self.method = method
self.controller = controller
self.request = request
callback(response)
class MockRpcController(service.RpcController):
Reported by Pylint.
Line: 54
Column: 9
class MockRpcChannel(service.RpcChannel):
def CallMethod(self, method, controller, request, response, callback):
self.method = method
self.controller = controller
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
Reported by Pylint.
Line: 55
Column: 9
def CallMethod(self, method, controller, request, response, callback):
self.method = method
self.controller = controller
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg
Reported by Pylint.
Line: 58
Column: 5
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg
self.callback_response = None
Reported by Pylint.
Line: 58
Column: 5
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg
self.callback_response = None
Reported by Pylint.
Line: 58
Column: 5
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg
self.callback_response = None
Reported by Pylint.
Line: 58
Column: 5
self.request = request
callback(response)
class MockRpcController(service.RpcController):
def SetFailed(self, msg):
self.failure_message = msg
self.callback_response = None
Reported by Pylint.
conformance/conformance_python.py
118 issues
Line: 40
Column: 1
import struct
import sys
import os
from google.protobuf import json_format
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
Reported by Pylint.
Line: 41
Column: 1
import sys
import os
from google.protobuf import json_format
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
Reported by Pylint.
Line: 42
Column: 1
import os
from google.protobuf import json_format
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
Reported by Pylint.
Line: 43
Column: 1
from google.protobuf import json_format
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
Reported by Pylint.
Line: 44
Column: 1
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
Reported by Pylint.
Line: 45
Column: 1
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
test_count = 0
Reported by Pylint.
Line: 62
Column: 3
if request.message_type == "conformance.FailureSet":
failure_set = conformance_pb2.FailureSet()
failures = []
# TODO(gerbens): Remove, this is a hack to detect if the old vs new
# parser is used by the cpp code. Relying on a bug in the old parser.
hack_proto = test_messages_proto2_pb2.TestAllTypesProto2()
old_parser = True
try:
hack_proto.ParseFromString(b"\322\002\001")
Reported by Pylint.
Line: 138
Column: 14
conformance_pb2.JSON_IGNORE_UNKNOWN_PARSING_TEST
json_format.Parse(request.json_payload, test_message,
ignore_unknown_fields)
except Exception as e:
response.parse_error = str(e)
return response
elif request.WhichOneof('payload') == 'text_payload':
try:
Reported by Pylint.
Line: 145
Column: 14
elif request.WhichOneof('payload') == 'text_payload':
try:
text_format.Parse(request.text_payload, test_message)
except Exception as e:
response.parse_error = str(e)
return response
else:
raise ProtocolError("Request didn't have payload.")
Reported by Pylint.
Line: 161
Column: 14
elif request.requested_output_format == conformance_pb2.JSON:
try:
response.json_payload = json_format.MessageToJson(test_message)
except Exception as e:
response.serialize_error = str(e)
return response
elif request.requested_output_format == conformance_pb2.TEXT_FORMAT:
response.text_payload = text_format.MessageToString(
Reported by Pylint.
java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java
111 issues
Line: 249
* limit for numBytes
*/
static void testBytes(
ByteStringFactory factory, int numBytes, long expectedCount, long start, long lim) {
Random rnd = new Random();
byte[] bytes = new byte[numBytes];
if (lim == -1) {
lim = 1L << (numBytes * 8);
Reported by PMD.
Line: 282
assertThat(Utf8.decodeUtf8(bytes, 0, numBytes)).isEqualTo(s);
} catch (InvalidProtocolBufferException e) {
if (isRoundTrippable) {
System.out.println("Could not decode utf-8");
outputFailure(byteChar, bytes, bytesReencoded);
}
}
// Test partial sequences.
Reported by PMD.
Line: 300
int state2 = Utf8.partialIsValidUtf8(state1, bytes, i, j);
int state3 = Utf8.partialIsValidUtf8(state2, bytes, j, numBytes);
if (isRoundTrippable != (state3 == Utf8.COMPLETE)) {
System.out.printf("state=%04x %04x %04x i=%d j=%d%n", state1, state2, state3, i, j);
outputFailure(byteChar, bytes, bytesReencoded);
}
assertThat((state3 == Utf8.COMPLETE)).isEqualTo(isRoundTrippable);
// Test ropes built out of small partial sequences
Reported by PMD.
Line: 335
}
count++;
if (byteChar != 0 && byteChar % 1000000L == 0) {
logger.info("Processed " + (byteChar / 1000000L) + " million characters");
}
}
logger.info("Round tripped " + countRoundTripped + " of " + count);
assertThat(countRoundTripped).isEqualTo(expectedCount);
}
Reported by PMD.
Line: 338
logger.info("Processed " + (byteChar / 1000000L) + " million characters");
}
}
logger.info("Round tripped " + countRoundTripped + " of " + count);
assertThat(countRoundTripped).isEqualTo(expectedCount);
}
/**
* Variation of {@link #testBytes} that does less allocation using the low-level encoders/decoders
Reported by PMD.
Line: 356
* limit for numBytes
*/
static void testBytesUsingByteBuffers(
ByteStringFactory factory, int numBytes, long expectedCount, long start, long lim) {
CharsetDecoder decoder =
Internal.UTF_8
.newDecoder()
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
Reported by PMD.
Line: 430
countRoundTripped++;
}
if (byteChar != 0 && byteChar % 1000000 == 0) {
logger.info("Processed " + (byteChar / 1000000) + " million characters");
}
}
logger.info("Round tripped " + countRoundTripped + " of " + count);
assertThat(countRoundTripped).isEqualTo(expectedCount);
}
Reported by PMD.
Line: 433
logger.info("Processed " + (byteChar / 1000000) + " million characters");
}
}
logger.info("Round tripped " + countRoundTripped + " of " + count);
assertThat(countRoundTripped).isEqualTo(expectedCount);
}
private static void outputFailure(long byteChar, byte[] bytes, byte[] after) {
outputFailure(byteChar, bytes, after, after.length);
Reported by PMD.
Line: 55
* @author jonp@google.com (Jon Perlow)
* @author martinrb@google.com (Martin Buchholz)
*/
final class IsValidUtf8TestUtil {
private static final Logger logger = Logger.getLogger(IsValidUtf8TestUtil.class.getName());
private IsValidUtf8TestUtil() {}
static interface ByteStringFactory {
Reported by PMD.
Line: 55
* @author jonp@google.com (Jon Perlow)
* @author martinrb@google.com (Martin Buchholz)
*/
final class IsValidUtf8TestUtil {
private static final Logger logger = Logger.getLogger(IsValidUtf8TestUtil.class.getName());
private IsValidUtf8TestUtil() {}
static interface ByteStringFactory {
Reported by PMD.
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java
110 issues
Line: 50
@RunWith(JUnit4.class)
public class FieldMaskTreeTest {
@Test
public void testAddFieldPath() throws Exception {
FieldMaskTree tree = new FieldMaskTree();
assertThat(tree.toString()).isEmpty();
tree.addFieldPath("");
assertThat(tree.toString()).isEmpty();
// New branch.
Reported by PMD.
Line: 52
@Test
public void testAddFieldPath() throws Exception {
FieldMaskTree tree = new FieldMaskTree();
assertThat(tree.toString()).isEmpty();
tree.addFieldPath("");
assertThat(tree.toString()).isEmpty();
// New branch.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
Reported by PMD.
Line: 54
FieldMaskTree tree = new FieldMaskTree();
assertThat(tree.toString()).isEmpty();
tree.addFieldPath("");
assertThat(tree.toString()).isEmpty();
// New branch.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// Redundant path.
tree.addFieldPath("foo");
Reported by PMD.
Line: 56
tree.addFieldPath("");
assertThat(tree.toString()).isEmpty();
// New branch.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// Redundant path.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// New branch.
Reported by PMD.
Line: 57
assertThat(tree.toString()).isEmpty();
// New branch.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// Redundant path.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// New branch.
tree.addFieldPath("bar.baz");
Reported by PMD.
Line: 60
assertThat(tree.toString()).isEqualTo("foo");
// Redundant path.
tree.addFieldPath("foo");
assertThat(tree.toString()).isEqualTo("foo");
// New branch.
tree.addFieldPath("bar.baz");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// Redundant sub-path.
tree.addFieldPath("foo.bar");
Reported by PMD.
Line: 63
assertThat(tree.toString()).isEqualTo("foo");
// New branch.
tree.addFieldPath("bar.baz");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// Redundant sub-path.
tree.addFieldPath("foo.bar");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// New branch from a non-root node.
tree.addFieldPath("bar.quz");
Reported by PMD.
Line: 65
tree.addFieldPath("bar.baz");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// Redundant sub-path.
tree.addFieldPath("foo.bar");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// New branch from a non-root node.
tree.addFieldPath("bar.quz");
assertThat(tree.toString()).isEqualTo("bar.baz,bar.quz,foo");
// A path that matches several existing sub-paths.
Reported by PMD.
Line: 66
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// Redundant sub-path.
tree.addFieldPath("foo.bar");
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// New branch from a non-root node.
tree.addFieldPath("bar.quz");
assertThat(tree.toString()).isEqualTo("bar.baz,bar.quz,foo");
// A path that matches several existing sub-paths.
tree.addFieldPath("bar");
Reported by PMD.
Line: 69
assertThat(tree.toString()).isEqualTo("bar.baz,foo");
// New branch from a non-root node.
tree.addFieldPath("bar.quz");
assertThat(tree.toString()).isEqualTo("bar.baz,bar.quz,foo");
// A path that matches several existing sub-paths.
tree.addFieldPath("bar");
assertThat(tree.toString()).isEqualTo("bar,foo");
}
Reported by PMD.
python/google/protobuf/internal/wire_format_test.py
105 issues
Line: 38
Column: 1
__author__ = 'robinson@google.com (Will Robinson)'
try:
import unittest2 as unittest #PY26
except ImportError:
import unittest
from google.protobuf import message
from google.protobuf.internal import wire_format
Reported by Pylint.
Line: 40
Column: 1
try:
import unittest2 as unittest #PY26
except ImportError:
import unittest
from google.protobuf import message
from google.protobuf.internal import wire_format
Reported by Pylint.
Line: 46
Column: 1
from google.protobuf.internal import wire_format
class WireFormatTest(unittest.TestCase):
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
Reported by Pylint.
Line: 48
Column: 1
class WireFormatTest(unittest.TestCase):
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
Reported by Pylint.
Line: 48
Column: 3
class WireFormatTest(unittest.TestCase):
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
Reported by Pylint.
Line: 48
Column: 3
class WireFormatTest(unittest.TestCase):
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
Reported by Pylint.
Line: 49
Column: 1
class WireFormatTest(unittest.TestCase):
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
# Number too high.
Reported by Pylint.
Line: 50
Column: 1
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
# Number too high.
self.assertRaises(message.EncodeError, PackTag, field_number, 6)
Reported by Pylint.
Line: 51
Column: 1
def testPackTag(self):
field_number = 0xabc
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
# Number too high.
self.assertRaises(message.EncodeError, PackTag, field_number, 6)
# Number too low.
Reported by Pylint.
Line: 53
Column: 5
tag_type = 2
self.assertEqual((field_number << 3) | tag_type,
wire_format.PackTag(field_number, tag_type))
PackTag = wire_format.PackTag
# Number too high.
self.assertRaises(message.EncodeError, PackTag, field_number, 6)
# Number too low.
self.assertRaises(message.EncodeError, PackTag, field_number, -1)
Reported by Pylint.