I’m a Japanese backend engineer, livining in Osaka, Japan.
tanimon / explorer Goto Github PK
View Code? Open in Web Editor NEWThis project forked from kusumotolab/kgenprog
An Exploratory Reordering Refactoring Tool
License: Other
This project forked from kusumotolab/kgenprog
An Exploratory Reordering Refactoring Tool
License: Other
各参照からその定義までの距離を計測している.
各参照から,その変数の直近の状態の変化(再代入,参照しているインスタンスの状態の変化)までの距離を計測する.
ステートメント並べ替えリファクタリングを行うため
==================== kGenProg Configuration ====================
targetProject = example/refactoring/Foo
executionTests = []
workingDir = /var/folders/fg/bcs1pclj33j6vfjs6ljs58s00000gn/T/kgenprog-work4556390598327865833
outDir = kgenprog-out
mutationGeneratingCount = 40
crossoverGeneratingCount = 0
headcount = 30
maxGeneration = 100
timeLimit = PT30M
testTimeLimit = PT10S
requiredSolutionsCount = 10
logLevel = INFO
randomSeed = 0
scope = PACKAGE
needNotOutput = false
currentDirectory = /Users/a-tanikd/src/github.com/a-tanikd/kgenprog
================================================================
2019-01-01 19:44:01 [main] [INFO] KGenProgMain - entered the era of 1st generation.
2019-01-01 19:44:03 [main] [INFO] KGenProgMain -
----------------------------------------------------------------
Elapsed time: 1 seconds
Variants: generated 40, syntax-valid 11, build-succeeded 2
Fitness: max 24.0(1), min 21.0(1), ave 22.5
----------------------------------------------------------------
2019-01-01 19:44:03 [main] [INFO] KGenProgMain - entered the era of 2nd generation.
2019-01-01 19:44:04 [main] [INFO] KGenProgMain -
----------------------------------------------------------------
Elapsed time: 2 seconds
Variants: generated 40, syntax-valid 0, build-succeeded 0
Fitness: max --, min --, ave NaN
----------------------------------------------------------------
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899)
at java.util.TimSort.mergeAt(TimSort.java:516)
at java.util.TimSort.mergeCollapse(TimSort.java:441)
at java.util.TimSort.sort(TimSort.java:245)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:348)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at jp.kusumotolab.kgenprog.ga.selection.AscendingVariantSelection.exec(AscendingVariantSelection.java:22)
at jp.kusumotolab.kgenprog.Strategies.execVariantSelection(Strategies.java:76)
at jp.kusumotolab.kgenprog.ga.variant.VariantStore.proceedNextGeneration(VariantStore.java:149)
at jp.kusumotolab.kgenprog.KGenProgMain.run(KGenProgMain.java:116)
at jp.kusumotolab.kgenprog.CUILauncher.launch(CUILauncher.java:58)
at jp.kusumotolab.kgenprog.CUILauncher.main(CUILauncher.java:30)
メトリクスが少しでも減少した個体を出力している.
ユーザが閾値を設定できるようにし,メトリクス値がその閾値を下回った個体だけを出力する.
Configuration
にオプションを作成し,JDTASTConstruction
等でその値を読むようにする
continue
文,break
文,return
文等を移動すると確実に処理フローが変化する.
これらのような文を移動しないように修正する.
SmellLocalization#exec
の返り値の List<Suspiciousness>
に重複した要素が含まれている.
重複した要素を削除する.
JDTOperation#apply
で java.lang.IllegalArgumentException: Node is not inside the AST
というエラーが多発する.次の条件が成り立つときに例外が発生する.
astNode.getAST() != astRewrite.getAST()
SmellLocalizationTest#testNestedSuspiciousness
でネストされた要素に対して Suspiciousness
が計測されているかをテストしている.
しかし,内実は要素数をカウントしているだけ.
より厳密にテストする.
KGenProgMain#run
でこうしてる
mutation.setCandidates(initialVariant.getGeneratedSourceCode()
.getProductAsts());
2つの問題が絡んでる
JDTASTLocation#locate
を呼び出したときに,Location が内部で保持している ASTNode
に対応するものが返ってこないことがある.
java -jar build/libs/kGenProg-1.1.0.jar \
-r example/refactoring/SumOf1To3 \
-s example/refactoring/SumOf1To3/src/example/Sum.java \
-t example/refactoring/SumOf1To3/src/example/SumTest.java \
--refactored-method example.Sum#sum \
--max-generation 100 \
--time-limit 60 \
--mutation-generating-count 20 \
--crossover-generating-count 0 \
--headcount 10 \
--required-solutions 10 \
-v
以下のように,MoveAfterOperation
内で,Location が内部で保持している ASTNode
と,locate
結果の ASTNode
を表示している.
https://github.com/a-tanikd/kGenProg/blob/01b9830d87159a2317a604cc21af22c40a3b782b/src/main/java/jp/kusumotolab/kgenprog/project/jdt/MoveAfterOperation.java#L28-L29
しかし,以下のログの最終行のように,これらが一致しないことがある.
...
2019-01-30 14:22:30 [main] [INFO] KGenProgMain - entered the era of 2nd generation.
2019-01-30 14:22:30 [main] [DEBUG] MoveAfterOperation - src : c=3;
-> c=3;
2019-01-30 14:22:30 [main] [DEBUG] MoveAfterOperation - dest: return a + b + c;
-> return a + b + c;
2019-01-30 14:22:30 [main] [DEBUG] MoveAfterOperation - src : int a;
-> int a;
2019-01-30 14:22:30 [main] [DEBUG] MoveAfterOperation - dest: c=3;
-> c=3;
2019-01-30 14:22:30 [main] [DEBUG] MoveAfterOperation - src : c=3;
-> int a;
...
スメルを実際に計測せずに固定値を与えている.
計測処理を実装する.
DefaultVariantSelection
では Fitness
がより大きい Variant
を選択している.
しかし,並べ替えリファクタリングでは Fitness
(= メトリクス値)が小さいものを選択したい.
Fitness
がより小さい Variant
を選択する VariantSelection
を実装する.
Interface や Enum を読み込むとバグる
Exception in thread "main" spoon.SpoonException: parseClass only considers classes (and not interfaces and enums). Please consider using a Launcher object for more advanced usage.
at spoon.Launcher.parseClass(Launcher.java:875)
at jp.kusumotolab.kgenprog.ga.MetricValidation.calculateFitness(MetricValidation.java:31)
revert 34a7496
移動先の node が移動させたい node 子だった場合に,移動させたい node が消えてしまう
FL および,Fitness 計測に用いるメトリクスを切り替え可能にする.
移動先は Suspiciouness が高い Location を選択している.
移動先の Location をランダムに選択する.
定義までの距離が長い参照を移動対象にしている.
各参照までの距離が長い定義を移動対象にする.
ビルド失敗する個体にビルド成功するが淘汰される.
VariantSelection
でビルド成功個体を優先的に選択するように修正する.
MetricValidation
でメトリクスを計測しているのは GeneratedSourceCode#getProductAsts
で取得できる AST 郡の先頭の要素のみ.
すべてのクラスのメトリクスを計測する.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.