forked from cqfn/jpeek
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cqfn#390 refactor and separate report generation from calculus
- Loading branch information
Showing
8 changed files
with
235 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2017-2019 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.jpeek; | ||
|
||
import com.jcabi.xml.XML; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
/** | ||
* Metrics calculus interface. | ||
* @since 0.1 | ||
* @todo #390:30min We have a separate interface to calculate XML metrics. | ||
* We should continue to the goal defined in #296 where we should have a java | ||
* implementation to calculate metrics. The motivation is to be able to make | ||
* calculations impossible or too difficult to implement in xsl. | ||
*/ | ||
public interface Calculus { | ||
|
||
/** | ||
* Produces {@link XML} representing metrics values. | ||
* @param metric Desired metric to calculate | ||
* @param params Params | ||
* @param skeleton Package input | ||
* @return XML document giving metrics values for classes | ||
* @throws IOException If fails | ||
*/ | ||
XML node(String metric, Map<String, Object> params, XML skeleton) | ||
throws IOException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2017-2019 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.jpeek; | ||
|
||
import com.jcabi.xml.Sources; | ||
import com.jcabi.xml.XML; | ||
import com.jcabi.xml.XSLDocument; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.cactoos.io.ResourceOf; | ||
import org.cactoos.text.FormattedText; | ||
import org.cactoos.text.TextOf; | ||
|
||
/** | ||
* Metrics xsl calculus. Use an xsl sheet to transform the input skeleton into | ||
* the xml containing the calculation. | ||
* @since 0.1 | ||
*/ | ||
public class XslCalculus implements Calculus { | ||
|
||
@Override | ||
public XML node(String metric, Map<String, Object> params, XML skeleton) | ||
throws IOException { | ||
return new XSLDocument( | ||
new TextOf( | ||
new ResourceOf( | ||
new FormattedText("org/jpeek/metrics/%s.xsl", metric) | ||
) | ||
).asString(), | ||
Sources.DUMMY, | ||
params | ||
).transform(skeleton); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.