kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.7k stars 275 forks source link

Increase the usage of compound assignment operators #323

Closed elfring closed 2 years ago

elfring commented 2 years ago

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of compound operators accordingly.

diff --git a/kse/src/org/kse/crypto/x509/GeneralNameUtil.java b/kse/src/org/kse/crypto/x509/GeneralNameUtil.java
index fbaf89c1..d642e871 100644
--- a/kse/src/org/kse/crypto/x509/GeneralNameUtil.java
+++ b/kse/src/org/kse/crypto/x509/GeneralNameUtil.java
@@ -218,7 +218,7 @@ public class GeneralNameUtil {

                try {
                    String netmaskString = InetAddress.getByAddress(netMask).getHostAddress();
-                   ipAddressString = ipAddressString + "/" + netmaskString;
+                   ipAddressString += "/" + netmaskString;
                } catch (UnknownHostException e) {
                    //length of IP address has been checked before
                }
diff --git a/kse/src/org/kse/gui/crypto/distributionpoints/DDistributionPointsChooser.java b/kse/src/org/kse/gui/crypto/distributionpoints/DDistributionPointsChooser.java
index 7ff285d3..b7c6936c 100644
--- a/kse/src/org/kse/gui/crypto/distributionpoints/DDistributionPointsChooser.java
+++ b/kse/src/org/kse/gui/crypto/distributionpoints/DDistributionPointsChooser.java
@@ -201,31 +201,31 @@ public class DDistributionPointsChooser extends JEscDialog {
        int reasons = 0;

        if (jcbUnused.isSelected()) {
-           reasons = reasons | ReasonFlags.unused;
+           reasons |= ReasonFlags.unused;
        }
        if (jcbKeyCompromise.isSelected()) {
-           reasons = reasons | ReasonFlags.keyCompromise;
+           reasons |= ReasonFlags.keyCompromise;
        }
        if (jcbCACompromise.isSelected()) {
-           reasons = reasons | ReasonFlags.cACompromise;
+           reasons |= ReasonFlags.cACompromise;
        }
        if (jcbAffiliationChanged.isSelected()) {
-           reasons = reasons | ReasonFlags.affiliationChanged;
+           reasons |= ReasonFlags.affiliationChanged;
        }
        if (jcbSuperseded.isSelected()) {
-           reasons = reasons | ReasonFlags.superseded;
+           reasons |= ReasonFlags.superseded;
        }
        if (jcbCessationOfOperation.isSelected()) {
-           reasons = reasons | ReasonFlags.cessationOfOperation;
+           reasons |= ReasonFlags.cessationOfOperation;
        }
        if (jcbCertificateHold.isSelected()) {
-           reasons = reasons | ReasonFlags.certificateHold;
+           reasons |= ReasonFlags.certificateHold;
        }
        if (jcbPrivilegeWithdrawn.isSelected()) {
-           reasons = reasons | ReasonFlags.privilegeWithdrawn;
+           reasons |= ReasonFlags.privilegeWithdrawn;
        }
        if (jcbAACompromise.isSelected()) {
-           reasons = reasons | ReasonFlags.aACompromise;
+           reasons |= ReasonFlags.aACompromise;
        }
        if (reasons > 0) {
            reasonFlags = new ReasonFlags(reasons);
diff --git a/kse/src/org/kse/gui/dialogs/importexport/DExportCertificates.java b/kse/src/org/kse/gui/dialogs/importexport/DExportCertificates.java
index 75a83acc..e1919264 100644
--- a/kse/src/org/kse/gui/dialogs/importexport/DExportCertificates.java
+++ b/kse/src/org/kse/gui/dialogs/importexport/DExportCertificates.java
@@ -240,16 +240,16 @@ public class DExportCertificates extends JEscDialog {
            jpOptions.add(jrbExportHead, gbc_jrbExportHead);
            jpOptions.add(jrbExportChain, gbc_jrbExportChain);
        } else {
-           gbc_jlExportFormat.gridy = gbc_jlExportFormat.gridy - 1;
-           gbc_jrbExportX509.gridy = gbc_jrbExportX509.gridy - 1;
-           gbc_jrbExportPkcs7.gridy = gbc_jrbExportPkcs7.gridy - 1;
-           gbc_jrbExportPkiPath.gridy = gbc_jrbExportPkiPath.gridy - 1;
-           gbc_jrbExportSpc.gridy = gbc_jrbExportSpc.gridy - 1;
-           gbc_jlExportPem.gridy = gbc_jlExportPem.gridy - 1;
-           gbc_jcbExportPem.gridy = gbc_jcbExportPem.gridy - 1;
-           gbc_jlExportFile.gridy = gbc_jlExportFile.gridy - 1;
-           gbc_jtfExportFile.gridy = gbc_jtfExportFile.gridy - 1;
-           gbc_jbBrowse.gridy = gbc_jbBrowse.gridy - 1;
+           gbc_jlExportFormat.gridy -= 1;
+           gbc_jrbExportX509.gridy -= 1;
+           gbc_jrbExportPkcs7.gridy -= 1;
+           gbc_jrbExportPkiPath.gridy -= 1;
+           gbc_jrbExportSpc.gridy -= 1;
+           gbc_jlExportPem.gridy -= 1;
+           gbc_jcbExportPem.gridy -= 1;
+           gbc_jlExportFile.gridy -= 1;
+           gbc_jtfExportFile.gridy -= 1;
+           gbc_jbBrowse.gridy -= 1;
        }

        jpOptions.add(jlExportFormat, gbc_jlExportFormat);
kaikramer commented 2 years ago

First of all, sorry for taking so long to respond. Then secondly thank you for contributing to the KSE project!

If you are willing to do more contributions in the future, then a PR would be preferrable to a patch file. This makes it easier to discuss certain parts of the code changes and to track the contributions in the commits. Anyway, thanks again!

elfring commented 2 years ago

Thanks for your small source code improvements.