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

Rewrite OpticsProcessor and write some tests for transforming #788

Merged
merged 16 commits into from
Apr 17, 2018
Merged

Rewrite OpticsProcessor and write some tests for transforming #788

merged 16 commits into from
Apr 17, 2018

Conversation

andrzejressel
Copy link
Contributor

I've remove silent failing when annotation is incorrect - now it throws error. I've also changed default value of array in optics to empty one.

build.gradle Outdated
maxParallelForks = Runtime.runtime.availableProcessors()
}

// build.dependsOn ':detekt'
Copy link
Member

Choose a reason for hiding this comment

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

Fiiiiix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Some cleanup and changes required.
Also, project indentation is now 2 instead of 4.

normalizedTargets.forEach { target ->

when (target) {
OpticsTarget.LENS -> annotatedLenses.addAll(evalAnnotatedLensElement(element).singleToList())
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick.
Unwrapping null with let, adding addNonNull or using knowError instead of logE seems clearer than singleToList imo.

Copy link
Contributor Author

@andrzejressel andrzejressel Apr 14, 2018

Choose a reason for hiding this comment

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

I haven't realized there is addIfNotNull method

}
}

private fun evalAnnotatedDslElement(element: Element): AnnotatedOptic? = when (element.getClassType()) {
Copy link
Member

Choose a reason for hiding this comment

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

evalAnnotatedOptionalElement, evalAnnotatedOptionalElement and evalAnnotatedDslElement is same method with only difference error message.


temp.listFiles().size shouldBe 1
temp.listFiles().size shouldBe 1
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 configurable? This doesn't work for i.e. DSL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be in next PR where I'll add DSL tests.

logE("Only data classes can have DSL target", element)
emptyList()
} else {
targets.toSet().plus(listOf(OpticsTarget.LENS, OpticsTarget.OPTIONAL)).toList()
Copy link
Member

Choose a reason for hiding this comment

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

targets.toList() + listOf(OpticsTarget.LENS, OpticsTarget.OPTIONAL)

Copy link
Member

Choose a reason for hiding this comment

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

This also removes the need for LensesFileGenerator(annotatedBounded, generatedDir).generate()and OptionalFileGenerator(annotatedBounded, generatedDir).generate()

return@forEach
}

val normalizedTargets = if (targets.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

This snippet could drastically be "simplified" using when.

@codecov
Copy link

codecov bot commented Apr 13, 2018

Codecov Report

Merging #788 into master will increase coverage by 2.43%.
The diff coverage is 44.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #788      +/-   ##
============================================
+ Coverage     41.01%   43.44%   +2.43%     
- Complexity      510      582      +72     
============================================
  Files           277      282       +5     
  Lines          7156     7211      +55     
  Branches        815      812       -3     
============================================
+ Hits           2935     3133     +198     
+ Misses         3961     3791     -170     
- Partials        260      287      +27
Impacted Files Coverage Δ Complexity Δ
...n/java/arrow/ap/objects/optional/OptionalSealed.kt 0% <ø> (ø) 0 <0> (?)
...odels/src/main/java/arrow/ap/objects/iso/IsoXXL.kt 0% <0%> (ø) 0 <0> (?)
...main/java/arrow/ap/objects/prism/PrismDataClass.kt 0% <0%> (ø) 0 <0> (?)
...dels/src/main/java/arrow/ap/objects/prism/Prism.kt 0% <0%> (ø) 0 <0> (?)
...ls/src/main/java/arrow/ap/objects/iso/IsoSealed.kt 0% <0%> (ø) 0 <0> (?)
.../src/main/java/arrow/ap/objects/lens/LensSealed.kt 0% <0%> (ø) 0 <0> (?)
...src/main/kotlin/arrow/optics/syntax/BoundSetter.kt 44.44% <37.5%> (ø) 4 <3> (ø) ⬇️
...ssor/src/main/java/arrow/optics/OpticsProcessor.kt 65.47% <64%> (+65.47%) 25 <23> (+25) ⬆️
...ssor/src/main/java/arrow/optics/AnnotatedDomain.kt 85.71% <84.61%> (+85.71%) 0 <0> (ø) ⬇️
... and 15 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 2cef324...37e3772. Read the comment docs.

@andrzejressel
Copy link
Contributor Author

@nomisRev I think it's ready

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

You should format with 2 spaces before merge.
Also how come codecov is failing this build?

@pakoito detekt not checking 2 space formatting?

@andrzejressel
Copy link
Contributor Author

andrzejressel commented Apr 17, 2018

@nomisRev I don't think so. There is nothing about spaces in docs: https://github.com/arturbosch/detekt/blob/master/docs/pages/documentation/style.md

EDIT: But on the other hand there is this: detekt/detekt@9ba1815

EDIT2: Also, build isn't "failing". My PR just have coverage lower than project's overall. But still it'll increase coverage.

@nomisRev
Copy link
Member

nomisRev commented Apr 17, 2018

@jereksel We have it configured here but it doesn't seem to work. Or at least not as I expect it to.

I'll just run formatter locally and merge.

Awesome work :)

EDIT: Ah I thought merging was blocked when not all checks passed. Which I translated to "failed".

@andrzejressel andrzejressel merged commit fc71961 into arrow-kt:master Apr 17, 2018
@andrzejressel andrzejressel deleted the feature/ap branch April 17, 2018 16:22
RawToast pushed a commit to RawToast/kategory that referenced this pull request Jul 18, 2018
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.

4 participants