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

Patch/#35 codacy issues #38

Merged
merged 16 commits into from
Apr 20, 2018
Merged

Patch/#35 codacy issues #38

merged 16 commits into from
Apr 20, 2018

Conversation

michaelhglass
Copy link
Member

A: Patched the kind of obvious PMD issues and left out some that we have to discuss further and code marked as duplicate by codacy.
This is mostly:

  • switch (default, break)
  • package private
  • define fields/variables before the rest
  • unnecessary constructors

B: Added .codacy.yml to exclude ptolemy plot and .js and .py files.

@coveralls
Copy link

coveralls commented Apr 8, 2018

Coverage Status

Coverage decreased (-0.08%) to 17.356% when pulling 2ce9dd0 on patch/#35-codacy-issues into b6c9465 on master.

*
* @param value
* @param valueToSet
* the value to set
* @throws InvocationTargetException
* thrown if the value cannot be assigned
*/
public void setValue(String value) throws InvocationTargetException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not the same as what is mentioned in @param

Copy link
Member Author

Choose a reason for hiding this comment

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

Corrected. Refactoring artifact.

@@ -70,7 +70,7 @@ public void start(String[] args) throws ClassNotFoundException {
String filename = null;
Class<? extends Task> taskClass = null;
if (args.length < 1) {
throw new RuntimeException("Specify the task class");
throw new ClassNotFoundException("Specify the task class");
Copy link
Collaborator

Choose a reason for hiding this comment

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

ClassNotFound is used for classpath Issues. Does this fit here? We should check the spec of CNF. Alternatively, IllegalArgumentExcpetion or IllegalStateException could also fit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it checks for at least one task class to be given as an argument, I think IllegalArgumentException is the best fit. Corrected.

protected double getMinDistance(Spea2IndividualSet w0) {
double min = Double.MAX_VALUE;
for (Spea2IndividualSet w1 : individualSets) {
if (w0 != w1) {
if (w0 == w1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Has this been a logic error? Then, we should outline this explicitly in the release notes of the next release and also make this bug fix release quite soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was an important catch! Thanks a lot. I made that mistake reverting back from equals(). Corrected.

@SDARG SDARG deleted a comment Apr 9, 2018
@SDARG SDARG deleted a comment Apr 9, 2018
@@ -32,8 +32,8 @@
* <p>
* A Java implementation of the MT19937 (Mersenne Twister) pseudo random
* number generator algorithm based upon the original C code by Makoto
* Matsumoto and Takuji Nishimura (see <a
* href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
* Matsumoto and Takuji Nishimura (see
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be handled with the new Citation annotation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I suggest separation of concerns and fix this in another patch to restrict this to codacy styling.

Copy link
Collaborator

@felixreimann felixreimann Apr 17, 2018

Choose a reason for hiding this comment

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

I did intentionally not use @citation here as the above references the code source, not a paper. Nonetheless, we can discuss if the corresponding paper should also be cited here, but this is SoC again.

@@ -8,6 +8,9 @@
import org.opt4j.core.genotype.PermutationGenotype;

public class IndividualTest {

private boolean stateChanged = false;
Copy link
Member

Choose a reason for hiding this comment

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

A proposition (not specifically targeted at this case): What do you think about making all class attributes protected instead of private. This makes writing tests a lot easier in many cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

SoC. Create different issue/patch.

Copy link
Collaborator

@felixreimann felixreimann left a comment

Choose a reason for hiding this comment

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

only minors, could also be merged directly.

for (int i = 0; i < pop.size(); i++) {
id.put(pop.get(i), i);
List<Individual> population = new ArrayList<Individual>(individuals);
Map<Individual, Integer> individualID = new HashMap<Individual, Integer>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

naming: better use plural for maps and sets. individualIds

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,5 @@
---
exclude_paths:
- 'opt4j-viewer/src/main/java/ptolemy/**/*'
Copy link
Collaborator

@felixreimann felixreimann Apr 17, 2018

Choose a reason for hiding this comment

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

What is your gut feeling. Should we also exclude all the unit tests or are the changes you did also senseful for them?

Copy link
Member Author

Choose a reason for hiding this comment

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

I reworked the tests, so I would keep it currently. Let us discuss this as part of issue #39.

Copy link
Collaborator

Choose a reason for hiding this comment

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

fine for me.

}

/**
* Helper function for crossover() to fill and rotate.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you extend the description a little bit? What is done in this function, what is done in the one above.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mentioned the respective cut point as the difference between the functions. The concrete algorithm is already detailed in the comment of the complete class so I would not detail the comment for helper functions further than the new one I committed.

@SDARG SDARG deleted a comment Apr 19, 2018
@michaelhglass michaelhglass merged commit 5a72265 into master Apr 20, 2018
@michaelhglass michaelhglass deleted the patch/#35-codacy-issues branch April 20, 2018 13:51
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.

None yet

4 participants