Add validator for lists of IP addresses Added as separate review per comment from Pino on review D15093. This code will not compile without the updated code in review D15520. Also includes unit test.
AbandonedPublic

Authored by andersonbruce on Sep 15 2018, 3:02 AM.

Details

Reviewers
jgrulich
pino
Summary

CCBUG: 397572
FIXED-IN: 5.14.0

Diff Detail

Repository
R116 Plasma Network Management Applet
Branch
IPAddressListValidator
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 2947
Build 2965: arc lint + arc unit
andersonbruce created this revision.Sep 15 2018, 3:02 AM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 15 2018, 3:02 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
andersonbruce requested review of this revision.Sep 15 2018, 3:02 AM
  • Correct overlooked comments from review D15093

Updating D15521: Add validator for lists of IP addresses

Added as separate review per comment from Pino on
review D15093. This code will not compile without
the updated code in review D15520. Also includes
unit test.

jgrulich added inline comments.Sep 17 2018, 5:52 AM
libs/editor/CMakeLists.txt
97

I'm sure you don't need to add all these and why did you remove PUBLIC and PRIVATE keywords?

106

Why removing it?

110

This is also an unrelated change.

libs/editor/simpleiplistvalidator.cpp
28

Fix indentation.

40

In both validator constructors (mean also for IPv6 one), you can directly pass "style" param from contructor, given both enums seem to be identical.

tests/CMakeLists.txt
10

Do we need these flags to be set? Please leak how simply can tested be added to CMake

[1] - https://cgit.kde.org/networkmanager-qt.git/tree/autotests/CMakeLists.txt

Maybe merge this review with D15520. I think they should go together.

pino requested changes to this revision.Sep 17 2018, 6:15 AM
libs/editor/simpleiplistvalidator.cpp
30

please set both m_ipv4Validator and m_ipv6Validator, otherwise they can be left uninitialized when type is not Both

63

no need for a regexp, please use QString::split() with QString::SkipEmptyParts

68

set (later on), but never use

102

result will never be QValidator::Invalid, so this condition is always true

tests/CMakeLists.txt
14–16

just use ecm_add_test instead

27–29

ditto

43–45

ditto

tests/simpleiplisttest.cpp
24

unused

44–46

even if this is a test, these are leaked, "polluting" the results of tools like valgrind; just make them non-pointers class variables

54

QVERIFY(foo == bar) -> QCOMPARE(foo, bar), it applies to all the checks in this file

This revision now requires changes to proceed.Sep 17 2018, 6:15 AM
  • Correct CMakefile I screwed up

Updating D15521: Add validator for lists of IP addresses

Added as separate review per comment from Pino on
review D15093. This code will not compile without
the updated code in review D15520. Also includes
unit test.

andersonbruce marked 3 inline comments as done.Sep 17 2018, 6:17 AM
andersonbruce added inline comments.
libs/editor/CMakeLists.txt
97

Damn, copied the wrong file. Sorry about that.

andersonbruce marked an inline comment as done.Sep 17 2018, 6:17 AM

Maybe merge this review with D15520. I think they should go together.

Can you please discuss this with Pino, he was the one who suggested separate reviews.
I will follow whatever you decide but if you decide that they should be merged please let me know how to do this.

andersonbruce added inline comments.Sep 17 2018, 10:15 AM
libs/editor/simpleiplistvalidator.cpp
40

They are the same now but initially they were not (I just added the WithPort option to IPv6) and my thought was that they may not necessarily stay identical in the future. If someone goes in and changes, say, the IPv4 version without realizing it affects the list validator, this code still works.

63

I used the regex so that it would split on commas with or without spaces around them and how I read SkipEmptyParts is that it will drop something between two adjacent commas which is not what I was trying to do.
Now I know that I could use "trimmed()" on the resulting strings to strip off any remaining spaces but I don't see any advantage to either using "trimmed()" every time I use one of the resulting strings or doing it once and creating another local copy of the strings for this purpose. It seemed to me that doing everything in one step was a just as viable approach unless there is something inherently bad with splitting on a regex that I am not aware of, especially given that I commented it to explain what it is doing.

68

I don't understand this comment. 'result' is set here to Acceptable, it can be modified to Intermediate at line 102 but if all the addresses are valid it needs to have been set initially to Acceptable for the return at line 106 to be correct.

tests/simpleiplisttest.cpp
54

Any particular reason you think this is superior?

Maybe merge this review with D15520. I think they should go together.

I believe that I have now moved all the changes from this review into review D15520 so this review can be deleted or marked obsolete or whatever you want to do with it. I also believe that all of the comments made here have been addressed in the changes updated to D15520.

Please mark this review as abandoned.

andersonbruce abandoned this revision.Sep 24 2018, 8:57 AM

Changes for this revision were merged into D15520