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

Five refactorings #45

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Conversation

robinroos
Copy link
Contributor

Five refactorings:

  • ”throws" declarations should not be superfluous
  • Static fields should not be updated in constructors (in this case the fields should not be static)
  • Unused "private" fields should be removed
  • Optimize Imports
  • Standard outputs should not be used directly to log anything (in this case suppress the warning since logging "to stdout" is the express purpose of the class SystemPrintLogger)

@robinroos
Copy link
Contributor Author

The next set of refactorings is ready.

@@ -68,10 +68,10 @@ public DockerDNSRRDiscoveryStrategy(
return discoveryNodes;
}

Set<InetAddress> serviceNameResolutions =
new HashSet<>();
// TODO robin - tighten scope of these variables
Copy link
Owner

Choose a reason for hiding this comment

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

remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already done in a pending PR which tightens variable scopes.

@@ -8,10 +8,9 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;

@SuppressWarnings("squid:S106")
Copy link
Owner

Choose a reason for hiding this comment

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

remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SuppressWarnings is already used in this project.

Copy link
Owner

Choose a reason for hiding this comment

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

yes, but not referencing third party tooling like this which is not used in the project

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. will remove as part of the next PR if that's ok.

@bitsofinfo
Copy link
Owner

Please just proceed with adding whatever other commits you have or are proposing to this PR if possible no need for a a bunch of different PRs if they are all just little things like this that are being dumped out of some automated code analyzer tool. thx

* @param logger
* @param properties
*/
public DockerSwarmDiscoveryStrategy(DiscoveryNode localDiscoveryNode, ILogger logger, Map<String, Comparable> properties) {
Copy link
Owner

@bitsofinfo bitsofinfo Mar 25, 2019

Choose a reason for hiding this comment

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

Do not alter/remove any public signatures/constructors. This could break others using this library in use-cases specific to them such as programmatically configuring the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The passed DiscoveryNode is never used. Surely best to clean that up with an appropriate release note? Happy to revert if you wish....

Copy link
Owner

Choose a reason for hiding this comment

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

Please remove it

@@ -36,7 +36,7 @@ public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode,
ILogger logger,
Map<String, Comparable> properties) {

return new DockerSwarmDiscoveryStrategy(discoveryNode, logger, properties);
Copy link
Owner

Choose a reason for hiding this comment

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

Do not alter/remove any public signatures/constructors. This could break others using this library in use-cases specific to them such as programmatically configuring the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The passed ILogger is never used. Surely best to clean that up with an appropriate release note? Happy to revert if you wish....

Copy link
Owner

Choose a reason for hiding this comment

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

Please remove it

@@ -46,9 +45,7 @@
/**
* Constructor
*/


public SwarmAddressPicker(final ILogger iLogger) {
Copy link
Owner

Choose a reason for hiding this comment

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

Do not alter/remove any public signatures/constructors. This could break others using this library in use-cases specific to them such as programmatically configuring the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The passed DiscoveryNode is never used. Surely best to clean that up with an appropriate release note? Happy to revert if you wish....

Copy link
Owner

Choose a reason for hiding this comment

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

Please remove it


// Since SwarmDiscoveryUtil is used by several components
// the context lets us distinguish instances in logs
private String context = null;

private ILogger logger = Logger.getLogger(SwarmDiscoveryUtil.class);

public SwarmDiscoveryUtil(String context,
Copy link
Owner

Choose a reason for hiding this comment

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

Do not alter/remove any public signatures/constructors. This could break others using this library in use-cases specific to them such as programmatically configuring the stack.

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 don't believe that constructor has actually changed recently. I would, however, love to get rid of "context" as it makes log messages longer than would otherwise be the case. Of course it might be that from a support perspective having SwarmDiscoveryUtil[CallingClass] in the log message has proven helpful.

Copy link
Owner

Choose a reason for hiding this comment

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

Leave the context.

Don't have time at the moment to go through each these diffs in detail but perhaps they are presented in confusing manner in this UI. I just see red removal here of an entire public constructor.

In any case, I don't mind formatting changes but do not alter or remove any pre-existing public method signatures or public constructors, regardless of if this library is internally calling it or not. Other users of this library could be calling these methods/constructors for other uses and this will maintain backwards compatibility.

Factor out processing of comma-delimited strings of tokens and properties
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.

2 participants