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

Bug/2948 wrong max one service path response #3034

Conversation

arigliano
Copy link
Contributor

This PR fixes #2948 Issue

  • It was implemented a new toJson() method in SubscriberError, in order to correctly print out the error response, depending on which serviceRoutine version calls either render() or toJson() method.
  • Fixed 400 httpStatusCode in both serviceRoutines

Implemented toJson() method in SubscribeContextResponse, SubscribeError
and SubscriptionId
…into bug/2948_wrong_max_one_service_path_response
- Fixed HttpStatusCode of the response
- New test for the fixed issue added
- New entry in CHANGES_NEXT_RELEASE added
*/
std::string SubscriptionId::toJson(RequestType container, bool comma)
{
std::string xString = string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really choose a really bad name to store id string in Subscriptions.h... :)

NTC (just a bit surprised of my/our self :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was probably me, smells KZ ... :-)
I don't find it that bad though :-D

NTC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for fun... blame shows this:

imagen

Very ancient code, probably from first commit in public repo... The origin of this variable is lost in History :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

99% sure it's mine :-)

@@ -47,6 +47,7 @@ typedef struct SubscriptionId
const char* c_str(void) const;
bool isEmpty(void);
std::string render(RequestType container,bool comma);
std::string toJson(RequestType container,bool comma);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: whitespace after ,

(I understand you take render() as reference, but it is also wrongly styled... could you please fix that line also, pls?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca

*/
std::string SubscribeContextResponse::toJson(void)
{
std::string out = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: excesive whitepace here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ Depends on what comes after. The '=' may be aligned with the '=' on the following line. If not, then yes ]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. In this case neither L66 (above) or L68 (below) has assignation stamente, thus my comment about excesive whitepace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca

@fgalan
Copy link
Member

fgalan commented Nov 6, 2017

Good work! Only minor comments.

Btw, do the branch in this PR pass make test and make style_check?

}
out += ",";
out += JSON_PROP("affectedItems") + "[" + JSON_STR(subscriptionId.toJson(requestType, true)) + "]";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation (one space seems to be missing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca

(subscriptionId.get() != "000000000000000000000000") &&
(subscriptionId.get() != ""))
{
out += ",";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca


#
# 01. Create subscription for E1 with multiple service paths header

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty line to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca

#

echo "01. Create subscription for E1 with multiple service paths header"
echo "=============================================================="
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more '='s, to be as long as the preceding line

Copy link
Member

@kzangeli kzangeli Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the description is not very correct.
Suggestion:

01. Attempt to create subscription for E1 with multiple service paths header, and see it fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7480bca

@kzangeli
Copy link
Member

kzangeli commented Nov 6, 2017

What Fermin said, good work!

@fgalan
Copy link
Member

fgalan commented Nov 14, 2017

@arigliano no news on this PR since a week ago... Are the feedback comments clear? Do you need any extra clarification? Don't hesitate to ask if you need, please.

Ermanno Mastrosimone and others added 2 commits November 15, 2017 10:26
@arigliano
Copy link
Contributor Author

Sorry for the late. With 7480bca commit, i've fixed the style issues.

  • make test passed

  • make style_check gives me a lot of errors regarding code parts that I did not touch.
    Starting in verbose mode,make style_check_v gives me the following:

style_check.sh: 111032 lines in 682 files in dir

0001 errors of category 'Do not leave a blank line after "public:"'
0001 errors of category 'Found C++ system header after other header'
0002 errors of category 'Extra space after ( in function call'
0003 errors of category 'Found C system header after other header'
0003 errors of category 'Missing space before ('
0003 errors of category 'Streams are highly discouraged'
0004 errors of category 'Single-argument constructors should be marked explicit'
0005 errors of category 'Line contains only semicolon'
0005 errors of category 'Missing spaces around ='
0006 errors of category 'Closing ) should be moved to the previous line'
0006 errors of category 'Include the directory when naming'
0008 errors of category 'Should have a space between // and comment'
0009 errors of category 'already included at'
0010 errors of category 'More than one command on the same line'
0011 errors of category 'Found C system header after C++ system header'
0013 errors of category '#endif line should be'
0013 errors of category '#ifndef header guard has wrong style'
0015 errors of category 'Do not use namespace using-directives'
0019 errors of category 'Blank line at the start of a code block'
0027 errors of category 'Missing space after ,'
0033 errors of category 'Labels should always be indented at least one space'
0038 errors of category 'Blank line at the end of a code block'
0044 errors of category 'Is this a non-const reference'
0045 errors of category 'Add #include'
0047 errors of category 'At least two spaces is best between code and comments'
0108 errors of category 'Tab found; better to use spaces'
0120 errors of category 'Extra space before ( in function call'
0133 errors of category 'Use int16/int64/etc'
0180 errors of category 'Line ends in whitespace'
0213 errors of category 'Weird number of spaces at line-start'
0249 errors of category 'Lines should be <= 120 characters long'

New style-guide errors:
-----------------------------------------------------
src/lib/common/JsonHelper.cpp:77: Extra space before last semicolon. If this should be an empty statement, use { } instead. [whitespace/semicolon] [5] src/lib/common/string.cpp:433: Complex multi-line /*...*/-style comment found. Lint may give bogus warnings. Consider replacing these with //-style comments, with #if 0...#endif, or with more clearly structured multi-line comments. [readability/multiline_comment] [5] src/lib/common/string.cpp:1055: Consider using gmtime_r(...) instead of gmtime(...) for improved thread safety. [runtime/threadsafe_fn] [2] src/lib/common/tag.cpp:191: Extra space before last semicolon. If this should be an empty statement, use { } instead. [whitespace/semicolon] [5] src/lib/ngsiNotify/Notifier.cpp:1: Complex multi-line /*...*/-style comment found. Lint may give bogus warnings. Consider replacing these with //-style comments, with #if 0...#endif, or with more clearly structured multi-line comments. [readability/multiline_comment] [5] src/lib/ngsiNotify/Notifier.cpp:0: One or more unexpected \r (^M) found;better to use only a \n [whitespace/newline] [1] src/lib/rest/httpRequestSend.cpp:0: One or more unexpected \r (^M) found;better to use only a \n [whitespace/newline] [1]
-----------------------------------------------------
style_check.sh: found 1381 errors (982 mayor, 392 minor errors) in 111032 lines of source code in 682 files (1.24% style-guide-incompatibilities)

I don't know if it is expected, but the errors in the part of code that I have modified are no longer there

@kzangeli
Copy link
Member

Try 'make style'.
Speaking from memory: I think you are executing style check on the entire code, all dirs.
Not all dirs are prepared still. Another make target, called 'style' (I think) uses a special script called 'style check from makefile'. Well, something like that :)

@arigliano
Copy link
Contributor Author

Ok thanks. I've performed '''make style''' and everything passed with no mayor error.

@fgalan
Copy link
Member

fgalan commented Nov 15, 2017

LGTM. Thx!

Passing the ball to @kzangeli for final LGTM

@kzangeli
Copy link
Member

LGTM

@fgalan fgalan merged commit 59b051c into telefonicaid:master Nov 15, 2017
@fgalan fgalan mentioned this pull request Nov 16, 2017
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

Successfully merging this pull request may close these issues.

Wrong "max one service-path allowed for subscriptions" in NGSIv2 subscription operation
3 participants