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

Deal with final scalastyle assessments: Issue 212 #249

Merged
merged 5 commits into from
Aug 9, 2018
Merged

Conversation

greebie
Copy link
Contributor

@greebie greebie commented Aug 7, 2018

GitHub issue(s):

#212

What does this Pull Request do?

It finishes off the scalastyle warnings by dealing with a number of null calls which scalastyle does not like.

image

Provides the final revisions to scalastyle problems, sometimes resulting in code refactoring.

In some cases, I felt like the Option[t] approach simplified the code and so I refactored (examples include ExtractDomain and ExtractLinks). These also had other style errors like using return.

I tried not to go overboard doing this, however.

In other cases, the only thing needed was to return an empty string "" instead of null.

In some cases, there seemed like no point in worrying about null. In this case, I used // scalastyle:off null Example is the NER stuff.

For tests, the nulls were kept as a way to break things. I used scalastyle:off null there as well.

Overall, whether we like the Option[t] approach or not, I think having the scalastyle stuff formalized and clean will be good for future. We can also just turn off the "null" setting in the configuration.

How should this be tested?

Because this involved some code refactoring of pretty major functions (ExtractDomain e.g.) I would suggest testing it with a messy set of warcs just to make sure I did not break things. For the most part, other than switching "nulls" to empty strings, all of the current tests are the same and passed.

For discussion, is the idea of outputting a default bad output string: something like "aut_empty" that could be set globally. However, for now I just went with empty string.

Additional Notes:

I made it so that using the Option[t] did not affect example scripts. In some ways it would be better for the functions to send out Option[t]s but it would mean that people would have to learn scala in more detail which is something we are pulling away from.

Interested parties

@ianmilligan1 @lintool (because of style issues raised) @ruebot

Thanks in advance for your help with the Archives Unleashed Toolkit!

greebie added 4 commits August 1, 2018 15:25
Remove try-catch from ExtractLinks as over kill. IOErrors should be caught in ArchiveRecordImpl (imho).
@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #249 into master will decrease coverage by 0.82%.
The diff coverage is 71.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #249      +/-   ##
==========================================
- Coverage   70.94%   70.11%   -0.83%     
==========================================
  Files          41       41              
  Lines        1005     1024      +19     
  Branches      180      191      +11     
==========================================
+ Hits          713      718       +5     
- Misses        235      240       +5     
- Partials       57       66       +9
Impacted Files Coverage Δ
...io/archivesunleashed/matchbox/TupleFormatter.scala 57.14% <ø> (ø) ⬆️
.../archivesunleashed/matchbox/ComputeImageSize.scala 100% <ø> (ø) ⬆️
src/main/scala/io/archivesunleashed/package.scala 84.11% <ø> (ø) ⬆️
...cala/io/archivesunleashed/app/CommandLineApp.scala 75.2% <ø> (ø) ⬆️
...ain/scala/io/archivesunleashed/ArchiveRecord.scala 83.33% <ø> (ø) ⬆️
...ala/io/archivesunleashed/matchbox/ComputeMD5.scala 100% <ø> (ø) ⬆️
.../io/archivesunleashed/matchbox/NERClassifier.scala 0% <0%> (ø) ⬆️
...ala/io/archivesunleashed/app/NERCombinedJson.scala 0% <0%> (ø) ⬆️
...n/scala/io/archivesunleashed/util/TweetUtils.scala 91.66% <100%> (ø) ⬆️
...la/io/archivesunleashed/matchbox/ExtractDate.scala 72.22% <54.54%> (-2.78%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77dbd51...f3ee305. Read the comment docs.

}
}

/** Extracts boilerplate.
Copy link
Member

Choose a reason for hiding this comment

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

Why is this function being removed?

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 believe the code on the right does the exact same job as the code on the left. I do not think the exception is needed. If it is, I think it would be better to catch the more specific issue coming from Exception and handle it accordingly with more detailed warnings. But I have not been able to think of a case, barring something really crazy hitting the server.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the code on the right does the exact same job as the code on the left?

Are you talking about a diff? Otherwise I don't gather what you're referring to here with left and right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - sorry. In the view I was using the changed code was on the right and the old code was on the left.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More clearly, the extract method is incorporated into apply with no (known) differences in the way ExtractBoilerplateText works.

Copy link
Member

Choose a reason for hiding this comment

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

Tested - and it works.

Copy link
Member

@ianmilligan1 ianmilligan1 left a comment

Choose a reason for hiding this comment

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

I've run through the docs with this and it all works.

}
}

/** Extracts boilerplate.
Copy link
Member

Choose a reason for hiding this comment

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

Tested - and it works.

@ruebot
Copy link
Member

ruebot commented Aug 8, 2018

Cool. I'll get this squashed and merged later on this evening then.

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.

3 participants