The following issues were found

python/google/protobuf/internal/reflection_test.py
2552 issues
No name 'unittest_import_pb2' in module 'google.protobuf'
Error

Line: 50 Column: 1

              except ImportError:
  import unittest

from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor

            

Reported by Pylint.

No name 'unittest_mset_pb2' in module 'google.protobuf'
Error

Line: 51 Column: 1

                import unittest

from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message

            

Reported by Pylint.

No name 'unittest_pb2' in module 'google.protobuf'
Error

Line: 52 Column: 1

              
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection

            

Reported by Pylint.

No name 'unittest_proto3_arena_pb2' in module 'google.protobuf'
Error

Line: 53 Column: 1

              from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import text_format

            

Reported by Pylint.

No name 'descriptor_pb2' in module 'google.protobuf'
Error

Line: 54 Column: 1

              from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import text_format
from google.protobuf.internal import api_implementation

            

Reported by Pylint.

No name 'more_extensions_pb2' in module 'google.protobuf.internal'
Error

Line: 60 Column: 1

              from google.protobuf import reflection
from google.protobuf import text_format
from google.protobuf.internal import api_implementation
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import wire_format
from google.protobuf.internal import test_util
from google.protobuf.internal import testing_refleaks

            

Reported by Pylint.

No name 'more_messages_pb2' in module 'google.protobuf.internal'
Error

Line: 61 Column: 1

              from google.protobuf import text_format
from google.protobuf.internal import api_implementation
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import wire_format
from google.protobuf.internal import test_util
from google.protobuf.internal import testing_refleaks
from google.protobuf.internal import decoder

            

Reported by Pylint.

No name 'message_set_extensions_pb2' in module 'google.protobuf.internal'
Error

Line: 62 Column: 1

              from google.protobuf.internal import api_implementation
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import wire_format
from google.protobuf.internal import test_util
from google.protobuf.internal import testing_refleaks
from google.protobuf.internal import decoder
from google.protobuf.internal import _parameterized

            

Reported by Pylint.

Invalid metaclass 'GeneratedProtocolMessageType' used
Error

Line: 1511 Column: 5

                      options=descriptor_pb2.MessageOptions(),
        # pylint: disable=protected-access
        create_key=descriptor._internal_create_key)
    class MyProtoClass(six.with_metaclass(reflection.GeneratedProtocolMessageType, message.Message)):
      DESCRIPTOR = mydescriptor
    myproto_instance = MyProtoClass()
    self.assertEqual(0, myproto_instance.foo_field)
    self.assertFalse(myproto_instance.HasField('foo_field'))
    myproto_instance.foo_field = 23

            

Reported by Pylint.

Invalid metaclass 'GeneratedProtocolMessageType' used
Error

Line: 1559 Column: 5

                  self.assertTrue('price' in desc.fields_by_name)
    self.assertTrue('owners' in desc.fields_by_name)

    class CarMessage(six.with_metaclass(reflection.GeneratedProtocolMessageType,
                                        message.Message)):
      DESCRIPTOR = desc

    prius = CarMessage()
    prius.name = 'prius'

            

Reported by Pylint.

python/google/protobuf/internal/message_test.py
2225 issues
No name 'map_proto2_unittest_pb2' in module 'google.protobuf'
Error

Line: 73 Column: 1

              except NameError:
  cmp = lambda x, y: (x > y) - (x < y)  # Python 3

from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool

            

Reported by Pylint.

No name 'map_unittest_pb2' in module 'google.protobuf'
Error

Line: 74 Column: 1

                cmp = lambda x, y: (x > y) - (x < y)  # Python 3

from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import message_factory

            

Reported by Pylint.

No name 'unittest_pb2' in module 'google.protobuf'
Error

Line: 75 Column: 1

              
from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import message_factory
from google.protobuf import text_format

            

Reported by Pylint.

No name 'unittest_proto3_arena_pb2' in module 'google.protobuf'
Error

Line: 76 Column: 1

              from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import message_factory
from google.protobuf import text_format
from google.protobuf.internal import api_implementation

            

Reported by Pylint.

No name 'descriptor_pb2' in module 'google.protobuf'
Error

Line: 77 Column: 1

              from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import message_factory
from google.protobuf import text_format
from google.protobuf.internal import api_implementation
from google.protobuf.internal import encoder

            

Reported by Pylint.

No name 'more_extensions_pb2' in module 'google.protobuf.internal'
Error

Line: 83 Column: 1

              from google.protobuf import text_format
from google.protobuf.internal import api_implementation
from google.protobuf.internal import encoder
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import packed_field_test_pb2
from google.protobuf.internal import test_util
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import message

            

Reported by Pylint.

No name 'packed_field_test_pb2' in module 'google.protobuf.internal'
Error

Line: 84 Column: 1

              from google.protobuf.internal import api_implementation
from google.protobuf.internal import encoder
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import packed_field_test_pb2
from google.protobuf.internal import test_util
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import message
from google.protobuf.internal import _parameterized

            

Reported by Pylint.

No name 'test_proto3_optional_pb2' in module 'google.protobuf.internal'
Error

Line: 86 Column: 1

              from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import packed_field_test_pb2
from google.protobuf.internal import test_util
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import message
from google.protobuf.internal import _parameterized

UCS2_MAXUNICODE = 65535

            

Reported by Pylint.

No name '_message' in module 'google.protobuf.pyext'
Error

Line: 2686 Column: 5

                  self.p_serialized = self.p.SerializeToString()

  def testAssertOversizeProto(self):
    from google.protobuf.pyext._message import SetAllowOversizeProtos
    SetAllowOversizeProtos(False)
    q = self.proto_cls()
    try:
      q.ParseFromString(self.p_serialized)
    except message.DecodeError as e:

            

Reported by Pylint.

Unable to import 'google.protobuf.pyext._message'
Error

Line: 2686 Column: 5

                  self.p_serialized = self.p.SerializeToString()

  def testAssertOversizeProto(self):
    from google.protobuf.pyext._message import SetAllowOversizeProtos
    SetAllowOversizeProtos(False)
    q = self.proto_cls()
    try:
      q.ParseFromString(self.p_serialized)
    except message.DecodeError as e:

            

Reported by Pylint.

java/lite/src/test/java/com/google/protobuf/LiteTest.java
1533 issues
This class has a bunch of public methods and attributes
Design

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 java.util.Collections.singletonList;


            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

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 java.util.Collections.singletonList;


            

Reported by PMD.

The type has an NCSS line count of 1716
Design

Line: 80

              import org.junit.runners.JUnit4;

/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer

            

Reported by PMD.

Avoid really long classes.
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

Possible God Class (WMC=127, ATFD=1,035, TCC=0.000%)
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

The class 'LiteTest' has a Modified Cyclomatic Complexity of 2 (Highest = 13).
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

The class 'LiteTest' has a total cyclomatic complexity of 127 (highest 14).
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

The class 'LiteTest' has a Standard Cyclomatic Complexity of 2 (Highest = 13).
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

The class 'LiteTest' has a NCSS line count of 1716 (Highest = 977).
Design

Line: 81

              
/** Test lite runtime. */
@RunWith(JUnit4.class)
public class LiteTest {

  @Before
  public void setUp() throws Exception {
    // Test that nested extensions are initialized correctly even if the outer
    // class has not been accessed directly.  This was once a bug with lite

            

Reported by PMD.

python/google/protobuf/internal/text_format_test.py
1497 issues
Bad option value 'g-import-not-at-top'
Error

Line: 44 Column: 1

              
import six

# pylint: disable=g-import-not-at-top
try:
  import unittest2 as unittest  # PY26
except ImportError:
  import unittest


            

Reported by Pylint.

No name 'any_pb2' in module 'google.protobuf'
Error

Line: 50 Column: 1

              except ImportError:
  import unittest

from google.protobuf import any_pb2
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2

            

Reported by Pylint.

No name 'any_test_pb2' in module 'google.protobuf'
Error

Line: 51 Column: 1

                import unittest

from google.protobuf import any_pb2
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2

            

Reported by Pylint.

No name 'map_unittest_pb2' in module 'google.protobuf'
Error

Line: 52 Column: 1

              
from google.protobuf import any_pb2
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2

            

Reported by Pylint.

No name 'unittest_custom_options_pb2' in module 'google.protobuf'
Error

Line: 53 Column: 1

              from google.protobuf import any_pb2
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any

            

Reported by Pylint.

No name 'unittest_mset_pb2' in module 'google.protobuf'
Error

Line: 54 Column: 1

              from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import message_set_extensions_pb2

            

Reported by Pylint.

No name 'unittest_pb2' in module 'google.protobuf'
Error

Line: 55 Column: 1

              from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import test_proto3_optional_pb2

            

Reported by Pylint.

No name 'unittest_proto3_arena_pb2' in module 'google.protobuf'
Error

Line: 56 Column: 1

              from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import test_util

            

Reported by Pylint.

No name 'descriptor_pb2' in module 'google.protobuf'
Error

Line: 57 Column: 1

              from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import test_util
from google.protobuf import descriptor_pool

            

Reported by Pylint.

No name 'any_test_pb2' in module 'google.protobuf.internal'
Error

Line: 58 Column: 1

              from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import message_set_extensions_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import test_util
from google.protobuf import descriptor_pool
from google.protobuf import text_format

            

Reported by Pylint.

python/google/protobuf/internal/python_message.py
994 issues
Bad option value 'g-import-not-at-top'
Error

Line: 965 Column: 1

                # TODO(amauryfa): Don't use the factory of generated messages.
  # To make Any work with custom factories, use the message factory of the
  # parent message.
  # pylint: disable=g-import-not-at-top
  from google.protobuf import symbol_database
  factory = symbol_database.Default()

  type_url = msg.type_url


            

Reported by Pylint.

TODO(robinson): Helpers for verbose, common checks like seeing if a
Error

Line: 33 Column: 3

              
# This code is meant to work on Python 2.4 and above only.
#
# TODO(robinson): Helpers for verbose, common checks like seeing if a
# descriptor's cpp_type is CPPTYPE_MESSAGE.

"""Contains a metaclass and helper functions used to create
protocol message classes from Descriptor objects at runtime.


            

Reported by Pylint.

Access to a protected member _ExtensionDict of a client class
Error

Line: 78 Column: 18

              
_FieldDescriptor = descriptor_mod.FieldDescriptor
_AnyFullTypeName = 'google.protobuf.Any'
_ExtensionDict = extension_dict._ExtensionDict

class GeneratedProtocolMessageType(type):

  """Metaclass for protocol message classes created at runtime from Descriptors.


            

Reported by Pylint.

TODO(robinson): Escape Python keywords (e.g., yield), and test this support.
Error

Line: 228 Column: 3

                  proto_field_name: The protocol message field name, exactly
      as it appears (or would appear) in a .proto file.
  """
  # TODO(robinson): Escape Python keywords (e.g., yield), and test this support.
  # nnorwitz makes my day by writing:
  # """
  # FYI.  See the keyword module in the stdlib. This could be as simple as:
  #
  # if keyword.iskeyword(proto_field_name):

            

Reported by Pylint.

TODO(kenton): Remove this method entirely if/when everyone agrees with my
Error

Line: 243 Column: 3

                #   the same transformation.  Note that currently if you name a field "yield",
  #   you can still access it just fine using getattr/setattr -- it's not even
  #   that cumbersome to do so.
  # TODO(kenton):  Remove this method entirely if/when everyone agrees with my
  #   position.
  return proto_field_name


def _AddSlots(message_descriptor, dictionary):

            

Reported by Pylint.

Unused argument 'message_descriptor'
Error

Line: 248 Column: 15

                return proto_field_name


def _AddSlots(message_descriptor, dictionary):
  """Adds a __slots__ entry to dictionary, containing the names of all valid
  attributes for this message type.

  Args:
    message_descriptor: A Descriptor instance describing this message type.

            

Reported by Pylint.

Access to a protected member _encoder of a client class
Error

Line: 324 Column: 3

                  sizer = type_checkers.TYPE_TO_SIZER[field_descriptor.type](
        field_descriptor.number, is_repeated, is_packed)

  field_descriptor._encoder = field_encoder
  field_descriptor._sizer = sizer
  field_descriptor._default_constructor = _DefaultValueConstructorForField(
      field_descriptor)

  def AddDecoder(wiretype, is_packed):

            

Reported by Pylint.

Access to a protected member _sizer of a client class
Error

Line: 325 Column: 3

                      field_descriptor.number, is_repeated, is_packed)

  field_descriptor._encoder = field_encoder
  field_descriptor._sizer = sizer
  field_descriptor._default_constructor = _DefaultValueConstructorForField(
      field_descriptor)

  def AddDecoder(wiretype, is_packed):
    tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)

            

Reported by Pylint.

Access to a protected member _default_constructor of a client class
Error

Line: 326 Column: 3

              
  field_descriptor._encoder = field_encoder
  field_descriptor._sizer = sizer
  field_descriptor._default_constructor = _DefaultValueConstructorForField(
      field_descriptor)

  def AddDecoder(wiretype, is_packed):
    tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
    decode_type = field_descriptor.type

            

Reported by Pylint.

Access to a protected member _default_constructor of a client class
Error

Line: 354 Column: 29

                    is_strict_utf8_check = _IsStrictUtf8Check(field_descriptor)
      field_decoder = decoder.StringDecoder(
          field_descriptor.number, is_repeated, is_packed,
          field_descriptor, field_descriptor._default_constructor,
          is_strict_utf8_check, clear_if_default)
    elif field_descriptor.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      field_decoder = type_checkers.TYPE_TO_DECODER[decode_type](
          field_descriptor.number, is_repeated, is_packed,
          field_descriptor, field_descriptor._default_constructor)

            

Reported by Pylint.

python/google/protobuf/text_format.py
949 issues
Bad option value 'g-import-not-at-top'
Error

Line: 61 Column: 1

              if six.PY3:
  long = int  # pylint: disable=redefined-builtin,invalid-name

# pylint: disable=g-import-not-at-top
__all__ = ['MessageToString', 'Parse', 'PrintMessage', 'PrintField',
           'PrintFieldValue', 'Merge', 'MessageToBytes']

_INTEGER_CHECKERS = (type_checkers.Uint32ValueChecker(),
                     type_checkers.Int32ValueChecker(),

            

Reported by Pylint.

Bad option value 'g-import-not-at-top'
Error

Line: 311 Column: 1

                  A Message instance of type matching type_name, or None if the a Descriptor
    wasn't found matching type_name.
  """
  # pylint: disable=g-import-not-at-top
  if descriptor_pool is None:
    from google.protobuf import descriptor_pool as pool_mod
    descriptor_pool = pool_mod.Default()
  from google.protobuf import symbol_database
  database = symbol_database.Default()

            

Reported by Pylint.

TODO(b/129989314) Import thread contention leads to test failures.
Error

Line: 45 Column: 3

              
__author__ = 'kenton@google.com (Kenton Varda)'

# TODO(b/129989314) Import thread contention leads to test failures.
import encodings.raw_unicode_escape  # pylint: disable=unused-import
import encodings.unicode_escape  # pylint: disable=unused-import
import io
import math
import re

            

Reported by Pylint.

Unused argument 'as_utf8'
Error

Line: 104 Column: 22

              
class TextWriter(object):

  def __init__(self, as_utf8):
    if six.PY2:
      self._writer = io.BytesIO()
    else:
      self._writer = io.StringIO()


            

Reported by Pylint.

TODO(haberman): refactor and optimize if this becomes an issue.
Error

Line: 452 Column: 3

                        # entire tree.  Unfortunately this would take significant refactoring
          # of this file to work around.
          #
          # TODO(haberman): refactor and optimize if this becomes an issue.
          entry_submsg = value.GetEntryClass()(key=key, value=value[key])
          self.PrintField(field, entry_submsg)
      elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
        if (self.use_short_repeated_primitives
            and field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE

            

Reported by Pylint.

Attribute '_allow_multiple_scalars' defined outside __init__
Error

Line: 821 Column: 5

              
  def ParseLines(self, lines, message):
    """Parses a text representation of a protocol message into a message."""
    self._allow_multiple_scalars = False
    self._ParseOrMerge(lines, message)
    return message

  def MergeLines(self, lines, message):
    """Merges a text representation of a protocol message into a message."""

            

Reported by Pylint.

Attribute '_allow_multiple_scalars' defined outside __init__
Error

Line: 827 Column: 5

              
  def MergeLines(self, lines, message):
    """Merges a text representation of a protocol message into a message."""
    self._allow_multiple_scalars = True
    self._ParseOrMerge(lines, message)
    return message

  def _ParseOrMerge(self, lines, message):
    """Converts a text representation of a protocol message into a message.

            

Reported by Pylint.

Access to a protected member _FindExtensionByNumber of a client class
Error

Line: 928 Column: 19

                      number = ParseInteger(name, True, True)
        field = message_descriptor.fields_by_number.get(number, None)
        if not field and message_descriptor.is_extendable:
          field = message.Extensions._FindExtensionByNumber(number)
      else:
        field = message_descriptor.fields_by_name.get(name, None)

        # Group names are expected to be capitalized as they appear in the
        # .proto file, which actually matches their type names, not their field

            

Reported by Pylint.

TODO(jieluo): Change to _allow_singular_overwrites.
Error

Line: 1043 Column: 3

                      sub_message = message.Extensions[field]
      else:
        # Also apply _allow_multiple_scalars to message field.
        # TODO(jieluo): Change to _allow_singular_overwrites.
        if (not self._allow_multiple_scalars and
            message.HasField(field.name)):
          raise tokenizer.ParseErrorPreviousToken(
              'Message type "%s" should not have multiple "%s" fields.' %
              (message.DESCRIPTOR.full_name, field.name))

            

Reported by Pylint.

TODO(dbarnett): Migrate violators to textformat_tokenizer.
Error

Line: 1573 Column: 3

                    self.token = self._current_line[self._column]

# Aliased so it can still be accessed by current visibility violators.
# TODO(dbarnett): Migrate violators to textformat_tokenizer.
_Tokenizer = Tokenizer  # pylint: disable=invalid-name


def _ConsumeInt32(tokenizer):
  """Consumes a signed 32bit integer number from tokenizer.

            

Reported by Pylint.

python/google/protobuf/internal/descriptor_pool_test.py
903 issues
No name 'unittest_import_pb2' in module 'google.protobuf'
Error

Line: 46 Column: 1

              except ImportError:
  import unittest

from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2

            

Reported by Pylint.

No name 'unittest_import_public_pb2' in module 'google.protobuf'
Error

Line: 47 Column: 1

                import unittest

from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2

            

Reported by Pylint.

No name 'unittest_pb2' in module 'google.protobuf'
Error

Line: 48 Column: 1

              
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2

            

Reported by Pylint.

No name 'descriptor_pb2' in module 'google.protobuf'
Error

Line: 49 Column: 1

              from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2

            

Reported by Pylint.

No name 'descriptor_pool_test1_pb2' in module 'google.protobuf.internal'
Error

Line: 51 Column: 1

              from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2

            

Reported by Pylint.

No name 'descriptor_pool_test2_pb2' in module 'google.protobuf.internal'
Error

Line: 52 Column: 1

              from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import no_package_pb2

            

Reported by Pylint.

No name 'factory_test1_pb2' in module 'google.protobuf.internal'
Error

Line: 53 Column: 1

              from google.protobuf.internal import api_implementation
from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import no_package_pb2
from google.protobuf.internal import testing_refleaks

            

Reported by Pylint.

No name 'factory_test2_pb2' in module 'google.protobuf.internal'
Error

Line: 54 Column: 1

              from google.protobuf.internal import descriptor_pool_test1_pb2
from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import no_package_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import descriptor

            

Reported by Pylint.

No name 'file_options_test_pb2' in module 'google.protobuf.internal'
Error

Line: 55 Column: 1

              from google.protobuf.internal import descriptor_pool_test2_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import no_package_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import descriptor
from google.protobuf import descriptor_database

            

Reported by Pylint.

No name 'more_messages_pb2' in module 'google.protobuf.internal'
Error

Line: 56 Column: 1

              from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf.internal import file_options_test_pb2
from google.protobuf.internal import more_messages_pb2
from google.protobuf.internal import no_package_pb2
from google.protobuf.internal import testing_refleaks
from google.protobuf import descriptor
from google.protobuf import descriptor_database
from google.protobuf import descriptor_pool

            

Reported by Pylint.

java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java
831 issues
This class has a bunch of public methods and attributes
Design

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 com.google.protobuf.Descriptors.Descriptor;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

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 com.google.protobuf.Descriptors.Descriptor;

            

Reported by PMD.

Possible God Class (WMC=124, ATFD=553, TCC=1.176%)
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

The class 'GeneratedMessageTest' has a Modified Cyclomatic Complexity of 1 (Highest = 11).
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

The class 'GeneratedMessageTest' has a Standard Cyclomatic Complexity of 1 (Highest = 11).
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

The class 'GeneratedMessageTest' has a total cyclomatic complexity of 124 (highest 11).
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

Avoid really long classes.
Design

Line: 85

               */
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 86

              @SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
@RunWith(JUnit4.class)
public class GeneratedMessageTest {
  TestUtil.ReflectionTester reflectionTester =
      new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);

  @After
  public void tearDown() {
    GeneratedMessageV3.setAlwaysUseFieldBuildersForTesting(false);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 95

                }

  @Test
  public void testGetFieldBuilderForExtensionField() {
    TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
    Message.Builder fieldBuilder =
        builder.getFieldBuilder(UnittestProto.optionalNestedMessageExtension.getDescriptor());
    int expected = 7432;
    FieldDescriptor field =

            

Reported by PMD.

python/google/protobuf/internal/json_format_test.py
789 issues
No name 'any_pb2' in module 'google.protobuf'
Error

Line: 47 Column: 1

              except ImportError:
  import unittest

from google.protobuf import any_pb2
from google.protobuf import duration_pb2
from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2

            

Reported by Pylint.

No name 'duration_pb2' in module 'google.protobuf'
Error

Line: 48 Column: 1

                import unittest

from google.protobuf import any_pb2
from google.protobuf import duration_pb2
from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2

            

Reported by Pylint.

No name 'field_mask_pb2' in module 'google.protobuf'
Error

Line: 49 Column: 1

              
from google.protobuf import any_pb2
from google.protobuf import duration_pb2
from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2

            

Reported by Pylint.

No name 'struct_pb2' in module 'google.protobuf'
Error

Line: 50 Column: 1

              from google.protobuf import any_pb2
from google.protobuf import duration_pb2
from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2

            

Reported by Pylint.

No name 'timestamp_pb2' in module 'google.protobuf'
Error

Line: 51 Column: 1

              from google.protobuf import duration_pb2
from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2

            

Reported by Pylint.

No name 'wrappers_pb2' in module 'google.protobuf'
Error

Line: 52 Column: 1

              from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool

            

Reported by Pylint.

No name 'any_test_pb2' in module 'google.protobuf'
Error

Line: 53 Column: 1

              from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool
from google.protobuf import json_format

            

Reported by Pylint.

No name 'unittest_mset_pb2' in module 'google.protobuf'
Error

Line: 54 Column: 1

              from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool
from google.protobuf import json_format
from google.protobuf.util import json_format_pb2

            

Reported by Pylint.

No name 'unittest_pb2' in module 'google.protobuf'
Error

Line: 55 Column: 1

              from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool
from google.protobuf import json_format
from google.protobuf.util import json_format_pb2
from google.protobuf.util import json_format_proto3_pb2

            

Reported by Pylint.

No name 'test_proto3_optional_pb2' in module 'google.protobuf.internal'
Error

Line: 56 Column: 1

              from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool
from google.protobuf import json_format
from google.protobuf.util import json_format_pb2
from google.protobuf.util import json_format_proto3_pb2


            

Reported by Pylint.

java/core/src/test/java/com/google/protobuf/MapTest.java
764 issues
This class has too many methods, consider refactoring it.
Design

Line: 59

              
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public class MapTest {

  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);

            

Reported by PMD.

Possible God Class (WMC=117, ATFD=423, TCC=0.000%)
Design

Line: 59

              
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public class MapTest {

  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);

            

Reported by PMD.

The class 'MapTest' has a total cyclomatic complexity of 117 (highest 9).
Design

Line: 59

              
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public class MapTest {

  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);

            

Reported by PMD.

Avoid really long classes.
Design

Line: 59

              
/** Unit tests for map fields. */
@RunWith(JUnit4.class)
public class MapTest {

  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 62

              public class MapTest {

  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);
  //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 63

              
  private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);
  //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");
    builder.getMutableInt32ToStringField().put(3, "33");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 64

                private void setMapValuesUsingMutableMap(TestMap.Builder builder) {
    builder.getMutableInt32ToInt32Field().put(1, 11);
    builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);
  //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");
    builder.getMutableInt32ToStringField().put(3, "33");
  //

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 66

                  builder.getMutableInt32ToInt32Field().put(2, 22);
    builder.getMutableInt32ToInt32Field().put(3, 33);
  //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");
    builder.getMutableInt32ToStringField().put(3, "33");
  //
    builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
    builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 67

                  builder.getMutableInt32ToInt32Field().put(3, 33);
  //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");
    builder.getMutableInt32ToStringField().put(3, "33");
  //
    builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
    builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
    builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 68

                //
    builder.getMutableInt32ToStringField().put(1, "11");
    builder.getMutableInt32ToStringField().put(2, "22");
    builder.getMutableInt32ToStringField().put(3, "33");
  //
    builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
    builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
    builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));
  //

            

Reported by PMD.