Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing whitespace in otherwise empty lines between conditionals of isEqual: return statement #15

Closed
macdrevx opened this issue Nov 15, 2011 · 4 comments

Comments

@macdrevx
Copy link
Contributor

This issue is present in commit 60ac436

Trailing whitespace should be eliminated for ease of use with repositories that reject commits with trailing whitespace.

@macdrevx
Copy link
Contributor Author

Note that this applies to the generated code.

@jparise
Copy link
Contributor

jparise commented Nov 15, 2011

Can you provide an example of the trailing whitespace in the generated code?

@macdrevx
Copy link
Contributor Author

The definition

message Demo {
    optional string demo_field_1 = 1;
    optional string demo_field_2 = 2;
    optional string demo_field_3 = 3;
    optional string demo_field_4 = 4;
    optional string demo_field_5 = 5;
    optional string demo_field_6 = 6;
}

results in the generated code:

- (BOOL) isEqual:(id)other {
  if (other == self) {
    return YES;
  }
  if (![other isKindOfClass:[Demo class]]) {
    return NO;
  }
  Demo *otherMessage = other;
  return
      self.hasDemoField1 == otherMessage.hasDemoField1 &&
      (!self.hasDemoField1 || [self.demoField1 isEqual:otherMessage.demoField1]) &&

      self.hasDemoField2 == otherMessage.hasDemoField2 &&
      (!self.hasDemoField2 || [self.demoField2 isEqual:otherMessage.demoField2]) &&

      self.hasDemoField3 == otherMessage.hasDemoField3 &&
      (!self.hasDemoField3 || [self.demoField3 isEqual:otherMessage.demoField3]) &&

      self.hasDemoField4 == otherMessage.hasDemoField4 &&
      (!self.hasDemoField4 || [self.demoField4 isEqual:otherMessage.demoField4]) &&

      self.hasDemoField5 == otherMessage.hasDemoField5 &&
      (!self.hasDemoField5 || [self.demoField5 isEqual:otherMessage.demoField5]) &&

      self.hasDemoField6 == otherMessage.hasDemoField6 &&
      (!self.hasDemoField6 || [self.demoField6 isEqual:otherMessage.demoField6]) &&

      (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
}

The trailing whitespace is on the otherwise empty lines in the return statement.

@macdrevx
Copy link
Contributor Author

Just recompiled with these fixes and found one more case. Here's the patch to fix it:

diff --git a/src/compiler/objc_enum_field.cc b/src/compiler/objc_enum_field.cc
index b85be1b..5e29026 100644
--- a/src/compiler/objc_enum_field.cc
+++ b/src/compiler/objc_enum_field.cc
@@ -215,7 +215,7 @@ namespace google { namespace protobuf { namespace compiler { namespace objective
   void EnumFieldGenerator::GenerateIsEqualCodeSource(io::Printer* printer) const {
     printer->Print(variables_,
       "self.has$capitalized_name$ == otherMessage.has$capitalized_name$ &&\n"
-      "(!self.has$capitalized_name$ || self.$name$ != otherMessage.$name$) &&\n");
+      "(!self.has$capitalized_name$ || self.$name$ != otherMessage.$name$) &&");
   }


jparise pushed a commit that referenced this issue Nov 15, 2011
This should complete the work for #15.
Packetdancer pushed a commit to Packetdancer/protobuf-objc that referenced this issue Feb 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants