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

cleanup IncognitoBrowser.cpp and support any firefox variant starting with "firefox-" #5788

Closed
wants to merge 5 commits into from

Conversation

teknsl
Copy link
Contributor

@teknsl teknsl commented Jan 4, 2025

discovered mozilla’s firefox nightly apt package .desktop file now points to a ‘firefox-bin’ executable path so thought instead of continually adding variants be ready for it in the code. cleaned up somewhat while i was there.

have not tested if logic is preserved on windows

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/util/IncognitoBrowser.cpp Outdated Show resolved Hide resolved

auto exec = entries.find("Exec");
if (exec != entries.end())
return parseDesktopExecProgram(exec->second.trimmed());
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
return parseDesktopExecProgram(exec->second.trimmed());
if (exec != entries.end()) {
return parseDesktopExecProgram(exec->second.trimmed());
}

src/util/IncognitoBrowser.cpp Outdated Show resolved Hide resolved
src/util/IncognitoBrowser.cpp Outdated Show resolved Hide resolved
// mozilla distributes many firefox variants with different endings so
// catch them all here, and be future proof at the same time :)
if (exeFilename.startsWith("firefox-"))
return "-private-window";
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
return "-private-window";
if (exeFilename.startsWith("firefox-")) {
return "-private-window";
}

if (exeFilename.startsWith("firefox-"))
return "-private-window";

for (const auto &pair : argTable)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
for (const auto &pair : argTable)
for (const auto &pair : argTable) {

src/util/IncognitoBrowser.cpp:87:

-                 return pair.second;
+                 return pair.second;
+ }


for (const auto &pair : argTable)
if (exeFilename == pair.first)
return pair.second;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
return pair.second;
if (exeFilename == pair.first) {
return pair.second;
}

getAssociatedExecutable(AssociationQueryType::Protocol, L"http");
QString browserExe = getExecutable();
if (browserExe.isNull())
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
return false;
if (browserExe.isNull()) {
return false;
}

L".htm");
}
QString browserArg = getPrivateArg(browserExe);
if (browserArg.isNull())
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

    if (browserArg.isNull())
                            ^

this fix will not be applied because it overlaps with another fix

}
QString browserArg = getPrivateArg(browserExe);
if (browserArg.isNull())
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]

src/util/IncognitoBrowser.cpp:101:

-     if (browserArg.isNull())
-         return false;
- 
-     return true;
+     return !browserArg.isNull();

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

if (exeFilename.startsWith("firefox-"))
return "-private-window";

for (const auto &pair : argTable)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
for (const auto &pair : argTable)
for (const auto &pair : argTable) {

src/util/IncognitoBrowser.cpp:91:

-                 return pair.second;
+                 return pair.second;
+ }


QString browserArg = getPrivateArg(browserExe);
if (browserArg.isNull())
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]

src/util/IncognitoBrowser.cpp:107:

-     if (browserArg.isNull())
-         return false;
- 
-     return true;
+     return !browserArg.isNull();

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

if (exeFilename.startsWith("firefox-"))
return "-private-window";

for (const auto &pair : argTable)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
for (const auto &pair : argTable)
for (const auto &pair : argTable) {

src/util/IncognitoBrowser.cpp:90:

-                 return pair.second;
+                 return pair.second;
+ }


QString browserArg = getPrivateArg(browserExe);
if (browserArg.isNull())
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]

src/util/IncognitoBrowser.cpp:108:

-     if (browserArg.isNull())
-         return false;
- 
-     return true;
+     return !browserArg.isNull();

return QProcess::startDetached(browserExe,
{getPrivateSwitch(browserExe), link});
QString exe = getExecutable();
QString arg = getPrivateArg(browserExe);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'browserExe' [clang-diagnostic-error]

    QString arg = getPrivateArg(browserExe);
                                ^

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

if (exeFilename.startsWith("firefox-"))
return "-private-window";

for (const auto &pair : argTable)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
for (const auto &pair : argTable)
for (const auto &pair : argTable) {

src/util/IncognitoBrowser.cpp:89:

-                 return pair.second;
+                 return pair.second;
+ }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i disagree with this but can get changed if need be

@teknsl
Copy link
Contributor Author

teknsl commented Jan 4, 2025

im apparently very tired.

@teknsl teknsl closed this Jan 4, 2025
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.

1 participant