The following issues were found
python/mox.py
551 issues
Line: 155
Column: 40
# A list of types that should be stubbed out with MockObjects (as
# opposed to MockAnythings).
_USE_MOCK_OBJECT = [types.ClassType, types.InstanceType, types.ModuleType,
types.ObjectType, types.TypeType]
def __init__(self):
"""Initialize a new Mox."""
Reported by Pylint.
Line: 155
Column: 23
# A list of types that should be stubbed out with MockObjects (as
# opposed to MockAnythings).
_USE_MOCK_OBJECT = [types.ClassType, types.InstanceType, types.ModuleType,
types.ObjectType, types.TypeType]
def __init__(self):
"""Initialize a new Mox."""
Reported by Pylint.
Line: 156
Column: 23
# A list of types that should be stubbed out with MockObjects (as
# opposed to MockAnythings).
_USE_MOCK_OBJECT = [types.ClassType, types.InstanceType, types.ModuleType,
types.ObjectType, types.TypeType]
def __init__(self):
"""Initialize a new Mox."""
self._mock_objects = []
Reported by Pylint.
Line: 156
Column: 41
# A list of types that should be stubbed out with MockObjects (as
# opposed to MockAnythings).
_USE_MOCK_OBJECT = [types.ClassType, types.InstanceType, types.ModuleType,
types.ObjectType, types.TypeType]
def __init__(self):
"""Initialize a new Mox."""
self._mock_objects = []
Reported by Pylint.
Line: 72
Column: 3
class Error(AssertionError):
"""Base exception for this module."""
pass
class ExpectedMethodCallsError(Error):
"""Raised when Verify() is called before all expected methods have been called
"""
Reported by Pylint.
Line: 193
Column: 7
"""Set all mock objects to replay mode."""
for mock_obj in self._mock_objects:
mock_obj._Replay()
def VerifyAll(self):
"""Call verify on all mock objects created."""
Reported by Pylint.
Line: 200
Column: 7
"""Call verify on all mock objects created."""
for mock_obj in self._mock_objects:
mock_obj._Verify()
def ResetAll(self):
"""Call reset on all mock objects. This does not unset stubs."""
for mock_obj in self._mock_objects:
Reported by Pylint.
Line: 206
Column: 7
"""Call reset on all mock objects. This does not unset stubs."""
for mock_obj in self._mock_objects:
mock_obj._Reset()
def StubOutWithMock(self, obj, attr_name, use_mock_anything=False):
"""Replace a method, attribute, etc. with a Mock.
This will replace a class or module with a MockObject, and everything else
Reported by Pylint.
Line: 243
Column: 5
"""
for mock in args:
mock._Replay()
def Verify(*args):
"""Verify mocks.
Reported by Pylint.
Line: 254
Column: 5
"""
for mock in args:
mock._Verify()
def Reset(*args):
"""Reset mocks.
Reported by Pylint.
python/google/protobuf/json_format.py
539 issues
Line: 45
Column: 1
__author__ = 'jieluo@google.com (Jie Luo)'
# pylint: disable=g-statement-before-imports,g-import-not-at-top
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict # PY26
# pylint: enable=g-statement-before-imports,g-import-not-at-top
Reported by Pylint.
Line: 45
Column: 1
__author__ = 'jieluo@google.com (Jie Luo)'
# pylint: disable=g-statement-before-imports,g-import-not-at-top
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict # PY26
# pylint: enable=g-statement-before-imports,g-import-not-at-top
Reported by Pylint.
Line: 50
Column: 1
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict # PY26
# pylint: enable=g-statement-before-imports,g-import-not-at-top
import base64
import json
import math
Reported by Pylint.
Line: 50
Column: 1
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict # PY26
# pylint: enable=g-statement-before-imports,g-import-not-at-top
import base64
import json
import math
Reported by Pylint.
Line: 59
Column: 1
from operator import methodcaller
import re
import sys
import six
from google.protobuf.internal import type_checkers
from google.protobuf import descriptor
Reported by Pylint.
Line: 277
Column: 7
js[name] = self._FieldToJsonObject(field, field.default_value)
except ValueError as e:
raise SerializeToJsonError(
'Failed to serialize {0} field: {1}.'.format(field.name, e))
return js
def _FieldToJsonObject(self, field, value):
Reported by Pylint.
Line: 407
Column: 5
try:
message_descriptor = pool.FindMessageTypeByName(type_name)
except KeyError:
raise TypeError(
'Can not find message descriptor by type_url: {0}.'.format(type_url))
message_class = db.GetPrototype(message_descriptor)
return message_class()
Reported by Pylint.
Line: 433
Column: 5
try:
js = json.loads(text, object_pairs_hook=_DuplicateChecker)
except ValueError as e:
raise ParseError('Failed to load JSON: {0}.'.format(str(e)))
return ParseDict(js, message, ignore_unknown_fields, descriptor_pool)
def ParseDict(js_dict,
message,
Reported by Pylint.
Line: 597
Column: 11
setattr(message, field.name, _ConvertScalarFieldValue(value, field))
except ParseError as e:
if field and field.containing_oneof is None:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
else:
raise ParseError(str(e))
except ValueError as e:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
except TypeError as e:
Reported by Pylint.
Line: 599
Column: 11
if field and field.containing_oneof is None:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
else:
raise ParseError(str(e))
except ValueError as e:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
except TypeError as e:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
Reported by Pylint.
python/google/protobuf/internal/containers.py
530 issues
Line: 78
Column: 16
def get(self, key, default=None):
try:
return self[key]
except KeyError:
return default
def __contains__(self, key):
try:
Reported by Pylint.
Line: 84
Column: 9
def __contains__(self, key):
try:
self[key]
except KeyError:
return False
else:
return True
Reported by Pylint.
Line: 94
Column: 18
return iter(self)
def itervalues(self):
for key in self:
yield self[key]
def iteritems(self):
for key in self:
yield (key, self[key])
Reported by Pylint.
Line: 95
Column: 15
def itervalues(self):
for key in self:
yield self[key]
def iteritems(self):
for key in self:
yield (key, self[key])
Reported by Pylint.
Line: 98
Column: 18
yield self[key]
def iteritems(self):
for key in self:
yield (key, self[key])
def keys(self):
return list(self)
Reported by Pylint.
Line: 99
Column: 21
def iteritems(self):
for key in self:
yield (key, self[key])
def keys(self):
return list(self)
def items(self):
Reported by Pylint.
Line: 105
Column: 21
return list(self)
def items(self):
return [(key, self[key]) for key in self]
def values(self):
return [self[key] for key in self]
# Mappings are not hashable by default, but subclasses can change this
Reported by Pylint.
Line: 105
Column: 43
return list(self)
def items(self):
return [(key, self[key]) for key in self]
def values(self):
return [self[key] for key in self]
# Mappings are not hashable by default, but subclasses can change this
Reported by Pylint.
Line: 108
Column: 15
return [(key, self[key]) for key in self]
def values(self):
return [self[key] for key in self]
# Mappings are not hashable by default, but subclasses can change this
__hash__ = None
def __eq__(self, other):
Reported by Pylint.
Line: 108
Column: 36
return [(key, self[key]) for key in self]
def values(self):
return [self[key] for key in self]
# Mappings are not hashable by default, but subclasses can change this
__hash__ = None
def __eq__(self, other):
Reported by Pylint.
java/core/src/main/java/com/google/protobuf/MessageSchema.java
497 issues
Line: 608
// If we make it here, the runtime still lies about what we know to be true at compile
// time. We throw to alert server monitoring for further remediation.
throw new RuntimeException(
"Field "
+ fieldName
+ " for "
+ messageClass.getName()
+ " not found. Known fields are "
Reported by PMD.
Line: 1180
@Override
public void mergeFrom(T message, T other) {
if (other == null) {
throw new NullPointerException();
}
for (int i = 0; i < buffer.length; i += INTS_PER_FIELD) {
// A separate method allows for better JIT optimizations
mergeSingleField(message, other, i);
}
Reported by PMD.
Line: 3854
public void mergeFrom(T message, Reader reader, ExtensionRegistryLite extensionRegistry)
throws IOException {
if (extensionRegistry == null) {
throw new NullPointerException();
}
mergeFromHelper(unknownFieldSchema, extensionSchema, message, reader, extensionRegistry);
}
/**
Reported by PMD.
Line: 4417
position = decodeStringRequireUtf8(data, position, registers);
break;
default:
throw new RuntimeException("unsupported field type.");
}
return position;
}
/** Decodes a map entry. */
Reported by PMD.
Line: 5542
MapEntryLite.writeTo(codedOutput, metadata, entry.getKey(), entry.getValue());
} catch (IOException e) {
// Writing to ByteString CodedOutputStream should not throw IOException.
throw new RuntimeException(e);
}
unknownFieldSchema.addLengthDelimited(unknownFields, number, codedBuilder.build());
it.remove();
}
}
Reported by PMD.
Line: 4357
/** Decodes a map entry key or value. Stores result in registers.object1. */
private int decodeMapEntryValue(
byte[] data,
int position,
int limit,
WireFormat.FieldType fieldType,
Class<?> messageType,
Registers registers)
throws IOException {
Reported by PMD.
Line: 4357
/** Decodes a map entry key or value. Stores result in registers.object1. */
private int decodeMapEntryValue(
byte[] data,
int position,
int limit,
WireFormat.FieldType fieldType,
Class<?> messageType,
Registers registers)
throws IOException {
Reported by PMD.
Line: 4357
/** Decodes a map entry key or value. Stores result in registers.object1. */
private int decodeMapEntryValue(
byte[] data,
int position,
int limit,
WireFormat.FieldType fieldType,
Class<?> messageType,
Registers registers)
throws IOException {
Reported by PMD.
Line: 4357
/** Decodes a map entry key or value. Stores result in registers.object1. */
private int decodeMapEntryValue(
byte[] data,
int position,
int limit,
WireFormat.FieldType fieldType,
Class<?> messageType,
Registers registers)
throws IOException {
Reported by PMD.
Line: 4357
/** Decodes a map entry key or value. Stores result in registers.object1. */
private int decodeMapEntryValue(
byte[] data,
int position,
int limit,
WireFormat.FieldType fieldType,
Class<?> messageType,
Registers registers)
throws IOException {
Reported by PMD.
java/core/src/test/java/com/google/protobuf/MapLiteTest.java
495 issues
Line: 51
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
Reported by PMD.
Line: 51
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
Line: 54
public final class MapLiteTest {
private void setMapValues(TestMap.Builder builder) {
builder
.putInt32ToInt32Field(1, 11)
.putInt32ToInt32Field(2, 22)
.putInt32ToInt32Field(3, 33)
.putInt32ToStringField(1, "11")
.putInt32ToStringField(2, "22")
Reported by PMD.
java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
495 issues
Line: 90
},
ITER_DIRECT {
@Override
CodedInputStream newDecoder(byte[] data, int blockSize) {
if (blockSize > DEFAULT_BLOCK_SIZE) {
blockSize = DEFAULT_BLOCK_SIZE;
}
ArrayList<ByteBuffer> input = new ArrayList<ByteBuffer>();
for (int i = 0; i < data.length; i += blockSize) {
Reported by PMD.
Line: 107
},
STREAM_ITER_DIRECT {
@Override
CodedInputStream newDecoder(byte[] data, int blockSize) {
if (blockSize > DEFAULT_BLOCK_SIZE) {
blockSize = DEFAULT_BLOCK_SIZE;
}
ArrayList<ByteBuffer> input = new ArrayList<ByteBuffer>();
for (int i = 0; i < data.length; i += blockSize) {
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.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertArrayEquals;
import protobuf_unittest.UnittestProto.BoolMessage;
Reported by PMD.
Line: 56
/** Unit test for {@link CodedInputStream}. */
@RunWith(JUnit4.class)
public class CodedInputStreamTest {
private static final int DEFAULT_BLOCK_SIZE = 4096;
private enum InputType {
ARRAY {
Reported by PMD.
Line: 56
/** Unit test for {@link CodedInputStream}. */
@RunWith(JUnit4.class)
public class CodedInputStreamTest {
private static final int DEFAULT_BLOCK_SIZE = 4096;
private enum InputType {
ARRAY {
Reported by PMD.
Line: 56
/** Unit test for {@link CodedInputStream}. */
@RunWith(JUnit4.class)
public class CodedInputStreamTest {
private static final int DEFAULT_BLOCK_SIZE = 4096;
private enum InputType {
ARRAY {
Reported by PMD.
Line: 56
/** Unit test for {@link CodedInputStream}. */
@RunWith(JUnit4.class)
public class CodedInputStreamTest {
private static final int DEFAULT_BLOCK_SIZE = 4096;
private enum InputType {
ARRAY {
Reported by PMD.
Line: 77
@Override
CodedInputStream newDecoder(byte[] data, int blockSize) {
ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
buffer.put(data);
buffer.flip();
return CodedInputStream.newInstance(buffer);
}
},
STREAM {
Reported by PMD.
Line: 78
CodedInputStream newDecoder(byte[] data, int blockSize) {
ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
buffer.put(data);
buffer.flip();
return CodedInputStream.newInstance(buffer);
}
},
STREAM {
@Override
Reported by PMD.
Line: 98
for (int i = 0; i < data.length; i += blockSize) {
int rl = Math.min(blockSize, data.length - i);
ByteBuffer rb = ByteBuffer.allocateDirect(rl);
rb.put(data, i, rl);
rb.flip();
input.add(rb);
}
return CodedInputStream.newInstance(input);
}
Reported by PMD.
java/core/src/test/java/com/google/protobuf/TestUtil.java
485 issues
Line: 3771
try {
ancestor = ancestor.getCanonicalFile();
} catch (IOException e) {
throw new RuntimeException("Couldn't get canonical name of working directory.", e);
}
String srcRootCheck = "src/google/protobuf";
// If we're running w/ Bazel on Windows, we're not in a sandbox, so we
Reported by PMD.
Line: 3791
ancestor = ancestor.getParentFile();
}
throw new RuntimeException(
"Could not find golden files. This test must be run from within the "
+ "protobuf source package so that it can read test data files from the "
+ "C++ source tree: "
+ initialPath);
}
Reported by PMD.
Line: 3819
return ByteString.copyFrom(
com.google.common.io.ByteStreams.toByteArray(TestUtil.class.getResourceAsStream(name)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Get the bytes of the "golden message". This is a serialized TestAllTypes with all fields set as
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.UnittestLite.defaultBoolExtensionLite;
import static com.google.protobuf.UnittestLite.defaultBytesExtensionLite;
import static com.google.protobuf.UnittestLite.defaultCordExtensionLite;
import static com.google.protobuf.UnittestLite.defaultDoubleExtensionLite;
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.UnittestLite.defaultBoolExtensionLite;
import static com.google.protobuf.UnittestLite.defaultBytesExtensionLite;
import static com.google.protobuf.UnittestLite.defaultCordExtensionLite;
import static com.google.protobuf.UnittestLite.defaultDoubleExtensionLite;
Reported by PMD.
Line: 254
*
* @author kenton@google.com Kenton Varda
*/
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
Reported by PMD.
Line: 254
*
* @author kenton@google.com Kenton Varda
*/
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
Reported by PMD.
Line: 254
*
* @author kenton@google.com Kenton Varda
*/
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
Reported by PMD.
Line: 254
*
* @author kenton@google.com Kenton Varda
*/
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
Reported by PMD.
Line: 254
*
* @author kenton@google.com Kenton Varda
*/
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
Reported by PMD.
java/core/src/test/java/com/google/protobuf/TextFormatTest.java
472 issues
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.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
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.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 73
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
*/
@RunWith(JUnit4.class)
public class TextFormatTest {
// A basic string with different escapable characters for testing.
private static final String ESCAPE_TEST_STRING =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 slashes \\";
Reported by PMD.
Line: 90
TestUtil.readTextFromFile("text_format_unittest_extensions_data.txt");
private static final String EXOTIC_TEXT =
""
+ "repeated_int32: -1\n"
+ "repeated_int32: -2147483648\n"
+ "repeated_int64: -1,\n"
+ "repeated_int64: -9223372036854775808\n"
+ "repeated_uint32: 4294967295\n"
Reported by PMD.
Line: 129
.replace(",", "");
private static final String MESSAGE_SET_TEXT =
""
+ "[protobuf_unittest.TestMessageSetExtension1] {\n"
+ " i: 123\n"
+ "}\n"
+ "[protobuf_unittest.TestMessageSetExtension2] {\n"
+ " str: \"foo\"\n"
Reported by PMD.
objectivec/DevTools/pddm.py
453 issues
Line: 477
Column: 7
@property
def lines(self):
captured_lines = SourceFile.SectionBase.lines.fget(self)
directive_len = len('//%PDDM-EXPAND')
result = []
for line in captured_lines:
result.append(line)
if self._macro_collection:
Reported by Pylint.
Line: 497
Column: 30
except PDDMError as e:
raise PDDMError('%s\n...while expanding "%s" from the section'
' that started:\n Line %d: %s' %
(e.message, macro,
self.first_line_num, self.first_line))
# Add the ending marker.
if len(captured_lines) == 1:
result.append('//%%PDDM-EXPAND-END %s' %
Reported by Pylint.
Line: 533
Column: 28
except PDDMError as e:
raise PDDMError('%s\n...while parsing section that started:\n'
' Line %d: %s' %
(e.message, self.first_line_num, self.first_line))
class ImportDefinesSection(SectionBase):
"""Section containing an import of PDDM-DEFINES from an external file."""
def __init__(self, first_line_num, import_resolver):
Reported by Pylint.
Line: 569
Column: 26
except PDDMError as e:
raise PDDMError('%s\n...while importing defines:\n'
' Line %d: %s' %
(e.message, self.first_line_num, self.first_line))
def _ParseFile(self):
self._sections = []
lines = self._original_content.splitlines()
cur_section = None
Reported by Pylint.
Line: 671
Column: 25
src_file.ProcessContent(strip_expansion=opts.collapse)
except PDDMError as e:
sys.stderr.write('ERROR: %s\n...While processing "%s"\n' %
(e.message, a_path))
return 101
if src_file.processed_content != src_file.original_content:
if not opts.dry_run:
print('Updating for "%s".' % a_path)
Reported by Pylint.
Line: 104
Column: 1
"""
import optparse
import os
import re
import sys
Reported by Pylint.
Line: 137
Column: 3
class PDDMError(Exception):
"""Error thrown by pddm."""
pass
class MacroCollection(object):
"""Hold a set of macros and can resolve/expand them."""
Reported by Pylint.
Line: 289
Column: 20
if macro_ref_str is None:
macro_ref_str = macro_ref_match.group('macro_ref')
name = macro_ref_match.group('name')
for prev_name, prev_macro_ref in macro_stack:
if name == prev_name:
raise PDDMError('Found macro recursion, invoking "%s":%s' %
(macro_ref_str, self._FormatStack(macro_stack)))
macro = self._macros[name]
args_str = macro_ref_match.group('args').strip()
Reported by Pylint.
Line: 386
Column: 31
self._lines = []
self._first_line_num = first_line_num
def TryAppend(self, line, line_num):
"""Try appending a line.
Args:
line: The line to append.
line_num: The number of the line.
Reported by Pylint.
Line: 386
Column: 25
self._lines = []
self._first_line_num = first_line_num
def TryAppend(self, line, line_num):
"""Try appending a line.
Args:
line: The line to append.
line_num: The number of the line.
Reported by Pylint.
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
423 issues
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.util;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableSet;
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.util;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableSet;
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 87
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class JsonFormatTest {
public JsonFormatTest() {
// Test that locale does not affect JsonFormat.
Locale.setDefault(Locale.forLanguageTag("hi-IN"));
}
Reported by PMD.
Line: 134
builder.addRepeatedInt64(234567890123456789L);
builder.addRepeatedUint32(678);
builder.addRepeatedUint64(345678901234567890L);
builder.addRepeatedSint32(012);
builder.addRepeatedSint64(456789012345678901L);
builder.addRepeatedFixed32(456);
builder.addRepeatedFixed64(567890123456789012L);
builder.addRepeatedSfixed32(890);
builder.addRepeatedSfixed64(678901234567890123L);
Reported by PMD.
Line: 149
builder.addRepeatedNestedMessageBuilder().setValue(200);
}
private void assertRoundTripEquals(Message message) throws Exception {
assertRoundTripEquals(message, TypeRegistry.getEmptyTypeRegistry());
}
private void assertRoundTripEquals(Message message, TypeRegistry registry) throws Exception {
JsonFormat.Printer printer = JsonFormat.printer().usingTypeRegistry(registry);
Reported by PMD.