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

STYLE: Replace Fill(0) with {} initializer for local variables in tests #4881

Conversation

N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Oct 14, 2024

Replaced code of the form

T var;
var.Fill(0);

with T var{};

Using Notepad++, Replace in Files, doing:

Find what: ^( [ ]+[^ ].* )(\w+);[\r\n]+ [ ]+\2\.Fill\(0\);
Replace with: $1$2{};
Filters: itk*Test*.cxx
[v] Match case
(*) Regular expression

The empty initializer list {} effectively zero-fills those variables.


When reviewing this pull request, it may be convenient to ignore whitespace changes: https://github.com/InsightSoftwareConsortium/ITK/pull/4881/files?w=1

@N-Dekker N-Dekker marked this pull request as ready for review October 14, 2024 19:08
@github-actions github-actions bot added area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module type:Style Style changes: no logic impact (indentation, comments, naming) area:Numerics Issues affecting the Numerics module labels Oct 15, 2024
@N-Dekker N-Dekker marked this pull request as draft October 16, 2024 14:46
Replaced code of the form

    T var;
    var.Fill(0);

with `T var{};`

Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+[^ ].* )(\w+);[\r\n]+ [ ]+\2\.Fill\(0\);
    Replace with: $1$2{};
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

The empty initializer list `{}` effectively zero-fills those variables.
@N-Dekker N-Dekker force-pushed the Replace-Fill-zero-on-index-variables branch from 2d1f199 to 1abc794 Compare October 16, 2024 15:03
@N-Dekker N-Dekker changed the title STYLE: Replace Fill(0) with {} initialization on index variables in tests STYLE: Replace Fill(0) with {} initializer for local variables in tests Oct 16, 2024
@N-Dekker N-Dekker marked this pull request as ready for review October 16, 2024 21:55
@dzenanz dzenanz merged commit 569a8b6 into InsightSoftwareConsortium:master Oct 17, 2024
13 checks passed
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 17, 2024
Replaced `Fill(0.)`, `Fill(0.0)`, `Fill(0.0f)`, and `Fill(0u)` calls with `{}`
initializers.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 17, 2024
Replaced `Fill(0.)`, `Fill(0.0)`, `Fill(0.0f)`, and `Fill(0u)` calls with `{}`
initializers.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
dzenanz pushed a commit that referenced this pull request Oct 18, 2024
Replaced `Fill(0.)`, `Fill(0.0)`, `Fill(0.0f)`, and `Fill(0u)` calls with `{}`
initializers.

Follow-up to pull request #4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    Type var;
    var.Fill(ElementType{});

with `Type var{};`

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ [^ ].*[ ])(\w+);[\r\n]+ [ ]+\2\.Fill\(.+{}\);
    Replace with: $1$2{};
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    SizeType size;
    size.Fill(x);

with `auto size = SizeType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ [^ ].*[ ])(\w+);[\r\n]+ [ ]+\2\.Fill\(.+{}\);
    Replace with: $1auto $3 = $2::Filled\($4\);
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    SizeType size;
    size.Fill(x);

with `auto size = SizeType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*Size.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    IndexType index;
    index.Fill(x);

with `auto index = IndexType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*::Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Find what: ^([ ]+ )(IndexType)[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    SizeType size;
    size.Fill(x);

with `auto size = SizeType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*Size.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::SizeType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    IndexType index;
    index.Fill(x);

with `auto index = IndexType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*::Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Find what: ^([ ]+ )(IndexType)[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::IndexType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    SizeType size;
    size.Fill(x);

with `auto size = SizeType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*Size.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::SizeType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    IndexType index;
    index.Fill(x);

with `auto index = IndexType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*::Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Find what: ^([ ]+ )(IndexType)[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::IndexType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    SizeType size;
    size.Fill(x);

with `auto size = SizeType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*Size.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::SizeType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 19, 2024
Replaced code of the form

    IndexType index;
    index.Fill(x);

with `auto index = IndexType::Filled(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(.*::Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Find what: ^([ ]+ )(IndexType)[ ]+(\w+);[\r\n]+ [ ]+\3\.Fill\(
    Replace with: $1auto $3 = $2::Filled\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Removed "typename" keywords from `typename T::::IndexType::Filled` calls.

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 22, 2024
Replaced code of the form

    T var;
    var.Fill(x);

with `auto var = itk::MakeFilled<T>(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
    Replace with: $1auto $3 = itk::MakeFilled<$2>\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to
- pull request InsightSoftwareConsortium#4881
- pull request InsightSoftwareConsortium#4884
- pull request InsightSoftwareConsortium#4887
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 23, 2024
Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
dzenanz pushed a commit that referenced this pull request Oct 24, 2024
Follow-up to pull request #4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 24, 2024
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+[^ ].* )(\w+);[\r\n]+ [ ]+\2\.Fill\(0\.?0?\);
    Replace with: $1$2{};
    Filters: itk*.cxx;itk*.hxx;itk*.h
    Directory: D:\Src\ITK\Modules
    [v] Match case
    (*) Regular expression

Follow-up to pull request InsightSoftwareConsortium#4881
commit 569a8b6
"STYLE: Replace Fill(0) with {} initializer for local variables in tests"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 24, 2024
Replaced code of the form

    T var;
    var.Fill(x);

with `auto var = itk::MakeFilled<T>(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
    Replace with: $1auto $3 = itk::MakeFilled<$2>\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to
- pull request InsightSoftwareConsortium#4881
- pull request InsightSoftwareConsortium#4884
- pull request InsightSoftwareConsortium#4887
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Oct 25, 2024
Replaced code of the form

    T var;
    var.Fill(x);

with `auto var = itk::MakeFilled<T>(x);`

Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always

Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
    Replace with: $1auto $3 = itk::MakeFilled<$2>\(
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to
- pull request InsightSoftwareConsortium#4881
- pull request InsightSoftwareConsortium#4884
- pull request InsightSoftwareConsortium#4887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Python wrapping Python bindings for a class area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module type:Style Style changes: no logic impact (indentation, comments, naming) type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants