Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JJUG_CCC_2017_Spring_to_upload.pdf

Kengo TODA
May 23, 2017
49

 JJUG_CCC_2017_Spring_to_upload.pdf

Kengo TODA

May 23, 2017
Tweet

More Decks by Kengo TODA

Transcript

  1. © Works Applications Co.,Ltd.
    #ccc_f3
    2017 May/20th, JJUG CCC 2017 Spring
    SpotBugs(FindBugs)ʹΑΔ
    େن໛ERPͷίʔυ඼࣭վળ
    1

    View full-size slide

  2. © Works Applications Co.,Ltd.
    #ccc_f3
    Agenda
    ‣ ࣗݾ঺հ
    ‣ 2017೥5݄ݱࡏͷJava੩తղੳπʔϧػೳɾಈ޲ൺֱ
    ‣ େن໛ERPͷίʔυ඼๊࣭͕͑Δ໰୊ͱͦͷղܾ
    ‣ ։ൃ͍ͯ͠Δ૊৫ͱͦͷ੡඼
    ‣ ߦ͍ͬͯΔ޻෉ͱࠓޙͷల๬
    2

    View full-size slide

  3. © Works Applications Co.,Ltd.
    #ccc_f3
    ͜ͷηογϣϯͰಘΒΕΔ΋ͷ
    ‣ େن໛։ൃʹͯӡ༻Մೳͳίʔυ඼࣭վળख๏
    ‣ άϩʔόϧͰେن໛ͳJava։ൃʹ͓͍ͯඞਢͱͳΔ

    ʮίʔυ඼࣭ͷఈ্͛ʯͷ࣮ફతͳख๏
    ‣ ࣾ಺FW΍ϥΠϒϥϦͷ࢖͍ํΛ޿ΊΔख๏ͱͯ͠

    ׆༻Ͱ͖Δ੩తղੳπʔϧϓϥάΠϯͷ։ൃख๏
    3

    View full-size slide

  4. © Works Applications Co.,Ltd.
    #ccc_f3
    ಥવͷQuiz
    4

    View full-size slide

  5. © Works Applications Co.,Ltd.
    #ccc_f3
    JJUG CCCͷCCCͱ͸ʁ
    1. ΫϥεɾνϣοτɾίϯύΠϧσΩϧ
    2. ௒ɾίʔσΟϯάɾίϯςετ
    3. ΫϩεɾίϛϡχςΟɾΧϯϑΝϨϯε
    5

    View full-size slide

  6. © Works Applications Co.,Ltd.
    #ccc_f3
    ࣗݾ঺հ
    ✤ https://github.com/
    KengoTODA/
    ✤ ᷂ϫʔΫεΞϓϦέʔγϣϯζ

    ݚڀ։ൃΤϯδχΞ
    ✤ ήʔϜ͕࡞Γͨͯ͘HSP2ʹ

    खΛग़͠ɺϑϦʔιϑτ΢ΣΞ
    ࡞ՈΛܦͯɺೖࣾ͠R&Dʹ
    ✤ SpotBugsͷதͷਓ
    JVM Simulator
    Maven3 ebook
    6

    View full-size slide

  7. © Works Applications Co.,Ltd.
    #ccc_f3
    1. 2017೥5݄ݱࡏͷ

    Java੩తղੳπʔϧػೳɾಈ޲ൺֱ
    7

    View full-size slide

  8. © Works Applications Co.,Ltd.
    #ccc_f3
    ੩తղੳπʔϧͷྑ͍ͱ͜Ζ
    ✤ ࢖͍खʹܦݧ΍ਂ͍஌͕ࣝͳͯ͘΋ɺ
    ✤ ϨϏϡʔલ΍σϓϩΠલͳͲૣ͍ஈ֊Ͱɺ
    ✤ ໰୊ΛൃݟͰ͖Δ
    8

    View full-size slide

  9. © Works Applications Co.,Ltd.
    #ccc_f3
    ൺֱର৅Java੩తղੳπʔϧ
    ‣ Checkstyle
    ‣ PMD
    ‣ FindBugs / SpotBugs
    ‣ Checker Framework
    ‣ Google error-prone
    9

    View full-size slide

  10. © Works Applications Co.,Ltd.
    #ccc_f3
    Checkstyle
    ‣ ιʔείʔυղੳͳͷͰίϯύΠϧͳ͠Ͱ࣮ߦͰ͖Δ
    ‣ ଟ࠼ͳIDEɾϏϧυπʔϧʹରԠ
    ‣ ίʔσΟϯάن໿ͷ֬ೝ͕ओ໨త
    ‣ ϓϥάΠϯ࣮૷ʹඞཁͳ஌͕ࣝগͳ͍
    ‣ http://checkstyle.sourceforge.net/
    10

    View full-size slide

  11. © Works Applications Co.,Ltd.
    #ccc_f3
    PMD
    ‣ ιʔείʔυղੳͳͷͰίϯύΠϧͳ͠Ͱ࣮ߦͰ͖Δ
    ‣ ଟ࠼ͳIDEɾϏϧυπʔϧͦͯ͠ݴޠʹରԠ
    ‣ CPDʢίϐϖݕग़ʣػೳ΋౥ࡌ
    ‣ ϓϥάΠϯ࣮૷͸ΘΓͱෳࡶ
    ‣ https://pmd.github.io/
    11

    View full-size slide

  12. © Works Applications Co.,Ltd.
    #ccc_f3
    FindBugs
    ‣ όΠτίʔυղੳͳͷͰίʔυʹͳ͍৘ใʢ਌Ϋϥεɺ

    ґଘઌɺΞϊςʔγϣϯ౳ʣ΋CLASSPATH͔Βิ׬Ͱ͖Δ
    ‣ ଟ࠼ͳIDEɾϏϧυπʔϧʹରԠ
    ‣ ϓϥάΠϯ࣮૷ʹ͸JVM΍όΠτίʔυͷ஌͕ࣝ͋Δͱྑ
    ͍
    ‣ https://spotbugs.github.io/
    12

    View full-size slide

  13. © Works Applications Co.,Ltd.
    #ccc_f3
    SpotBugsͱ͸ʁ
    ‣ FindBugsͷ։ൃ͕͠͹Β͘ࢭ·͍ͬͯͨʢ3.0.1͸2೥
    ऑલͷϦϦʔεʣ
    ‣ 3.1.0ϦϦʔε४උˍίϛϡχςΟܗ੒த
    ✤ FindBugsίϛϡχςΟʹ͓͚Δྫͷ݅ͷహ຤ɺͦ͠
    ͯSpotBugsͱ͸Կ͔
    13

    View full-size slide

  14. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟɿJSR305Ξϊςʔγϣϯͷࠓ
    ‣ javax.annotation ύοέʔδʹؚ·ΕΔ

    ˏNonnull ΍ˏUntaintedͳͲͷΞϊςʔγϣϯ
    ‣ JSR305͕Dormantͱͳͬͨޙ΋FindBugs͕഑෍͍ͯͨ͠
    ‣ SpotBugsʹΑΔϝϯςφϯε༧ఆແ͠
    ‣ ܕύϥϝʔλʹ࢖͏͜ͱ΋Ͱ͖ͳ͍ͷͰ

    ࠓޙԺ΍͔ʹஔ͖׵͑ΒΕ͍ͯ͘ͷͰ͸
    14

    View full-size slide

  15. © Works Applications Co.,Ltd.
    #ccc_f3
    Checker Framework
    ‣ Java8ͷJSR 308 (Annotations on Java Types) Λར༻͢Δ
    ‣ ଟ࠼ͳIDEɾϏϧυπʔϧʹରԠ
    ‣ JDKʹؚ·ΕΔΫϥεͷৼΔ෣͍Λσʔλϕʔεʹ࣋ͭ
    ‣ https://checkerframework.org/
    15

    View full-size slide

  16. © Works Applications Co.,Ltd.
    #ccc_f3
    Google error-prone
    ‣ ίϯύΠϧ࣌ʹղੳ͢ΔͷͰίʔυʹͳ͍৘ใ΋र͍΍͍͢
    ‣ ιʔείʔυͷࣗಈमਖ਼Λ౰ॳ͔Βҙ͍ࣝͯ͠Δʁ
    ‣ EclipseඇରԠʢcom.sun.* ύοέʔδʹґଘͷͨΊʣ
    ‣ ৭ʑϞμϯͰϓϥάΠϯ࣮૷΋͠΍͍͢
    ‣ GoogleࣾһҎ֎͔ΒͷPR͸ʢ࣮੷ͱͯ͠ʣड͚෇͚ͯͳ͍
    ‣ http://errorprone.info/
    16
    Refs: http://dl.acm.org/citation.cfm?id=2486877

    View full-size slide

  17. © Works Applications Co.,Ltd.
    #ccc_f3
    ࠓ࢖͏ͳΒͲͷπʔϧʁ
    17
    ʘ Target Standard Rules Note
    Checkstyle
    7.7
    AST 152 checks codingن໿
    PMD
    5.6.1
    AST 287 rules
    (PMD Java)
    ଟݴޠରԠ
    SpotBugs
    3.1.0−RC2
    Bytecode
    453 patterns
    (+9 experimentals)
    plugin๛෋
    Checker Fw
    2.1.11
    AST
    (Compiler֦ு)
    19 checkers JSR308ରԠ
    error-prone
    v2.0.19
    AST
    (Compiler֦ு)
    145 patterns
    (+61 experimentals)
    কདྷʹظ଴

    View full-size slide

  18. © Works Applications Co.,Ltd.
    #ccc_f3
    ࠓ࢖͏ͳΒͲͷπʔϧʁ
    ‣ ͱʹ͔͘਺Λग़͍ͨ͠
    ‣ SpotBugs + Checker Framework
    ‣ Type AnnotationΛ࢖͑͹SpotBugsʹݟ͚ͭΒΕͳ͍໰୊΋

    ᖰΓग़ͤΔՄೳੑ͕͋Δ
    ‣ ղੳʹ࣌ؒΛ͔͚ͨ͘ͳ͍
    ‣ error-proneͰίϯύΠϧ࣌νΣοΫ
    ‣ PMDΛίϯύΠϥͱฒྻ࣮ߦ
    18

    View full-size slide

  19. © Works Applications Co.,Ltd.
    #ccc_f3
    ࠓ࢖͏ͳΒͲͷπʔϧʁ
    ‣ JavaεΩϧͷߴ͍։ൃऀ͕ἧ͍ͬͯΔ
    ‣ Ξϊςʔγϣϯͷར༻Λଅਐ͠Checker FrameworkΛ׆༻͢Δ
    ‣ ఆظతͳSpotBugsͰࡉ͔͍໰୊΋ᖰΓग़͢
    ‣ ։ൃऀͷJavaεΩϧʹ͹Β͖͕ͭ͋Δ
    ‣ CheckstyleͰ࠷௿ݶͷಡΈ΍͢͞Λ୲อ͢Δ
    ‣ CPDͰίϐϖʹܯࠂΛ͢Δʢઅ౓ͷ͋ΔίϐϖΛଅ͢ʣ
    ‣ ಈ࡞Λܰͨ͘͠PMD΍SpotBugsΛ͜·Ίʹճ͠࠷௿ݶͷϛεΛ๷͙
    19

    View full-size slide

  20. © Works Applications Co.,Ltd.
    #ccc_f3
    Agenda
    ‣ ࣗݾ঺հ
    ‣ 2017೥5݄ݱࡏͷJava੩తղੳπʔϧػೳɾಈ޲ൺֱ
    ‣ େن໛ERPͷίʔυ඼๊࣭͕͑Δ໰୊ͱͦͷղܾ
    ‣ ։ൃ͍ͯ͠Δ૊৫ͱͦͷ੡඼
    ‣ ߦ͍ͬͯΔ޻෉ͱࠓޙͷల๬
    20

    View full-size slide

  21. © Works Applications Co.,Ltd.
    #ccc_f3
    2. େن໛ERPͷίʔυ඼࣭͕
    ๊͑Δ໰୊
    21

    View full-size slide

  22. © Works Applications Co.,Ltd.
    #ccc_f3
    גࣜձࣾ
    ϫʔΫεΞϓϦέʔγϣϯζͱ͸
    ✤ ERPύοέʔδͷ։ൃΛߦ͍ͬͯΔاۀ
    ✤ γϯΨϙʔϧɺதࠃɺΠϯυɺΞϝϦΧ౳ʹ΋ڌ఺
    ✤ ίϯγϡʔϚΞϓϦͷΑ͏ͳϢʔβϏϦςΟͱ

    εϐʔυΛ࣋ͭERPʮHUEʢAI WorksʣʯΛ

    ։ൃɾఏڙ
    22

    View full-size slide

  23. © Works Applications Co.,Ltd.
    #ccc_f3
    HUEͷ࣮૷
    ✤ ୤RDB͢ΔͳͲ଎౓ʹͩ͜Θ͍ͬͯͯɺ
    ✤ MSA͠ͳ͍ͱࢮ͵ఔ౓ʹ͸ࢁ΄ͲαʔϏε͕͋Γɺ
    ✤ ಙౡʹݚڀॴ࡞ΔϨϕϧͰࣗવݴޠॲཧʹຊؾͰɺ
    ✤ 100msୡ੒ͷͨΊʹAWS LambdaΛಋೖ͢ΔͳͲ

    ৽͍͜͠ͱ΋৭ʑ΍͍ͬͯΔɻ
    23

    View full-size slide

  24. © Works Applications Co.,Ltd.
    #ccc_f3
    HUEͷ࣮૷Λࢧ͑Δਓ
    ✤ ඇৗʹଟ࠼Ͱ௕ॴ΋ଟ͍
    ✤ ౦ژɾେࡕɾνΣϯφΠɾ্ւɾγϯΨϙʔϧͳͲʹ

    ։ൃڌ఺͕෼ࢄ͍ͯ͠Δ
    ✤ ड͚ͨڭҭ΍ৗ͔ࣝΒͯ͠େ͖͘ҧ͏
    ✤ ϑϩϯτΤϯυɺϑϨʔϜϫʔΫɺϞόΠϧɺػցֶशɺ

    όονɺ෼ࢄॲཧͱ͍༷ͬͨʑͳઐ໳Ո͕ڞଘ
    ✤ εΩϧͷͳ͍৽ਓ͕૿͑ଓ͚͍ͯΔঢ়ଶ
    24

    View full-size slide

  25. © Works Applications Co.,Ltd.
    #ccc_f3
    HUEͷ࣮૷Λࢧ͑Δਓ
    ✤ ඇৗʹଟ࠼Ͱ௕ॴ΋ଟ͍
    ✤ ౦ژɾେࡕɾνΣϯφΠɾ্ւɾγϯΨϙʔϧͳͲʹ

    ։ൃڌ఺͕෼ࢄ͍ͯ͠Δ
    ✤ ड͚ͨڭҭ΍ৗ͔ࣝΒͯ͠େ͖͘ҧ͏
    ✤ ϑϩϯτΤϯυɺϑϨʔϜϫʔΫɺϞόΠϧɺػցֶशɺ

    όονɺ෼ࢄॲཧͱ͍༷ͬͨʑͳઐ໳Ո͕ڞଘ
    ✤ εΩϧͷͳ͍৽ਓ͕૿͑ଓ͚͍ͯΔঢ়ଶ
    25
    ໰ɿ
    ߴ଎ʹ૿͍͑ͯ͘
    ։ൃऀͷΩϟονΞοϓΛ
    গͳ͍ίϛϡχέʔγϣϯͰ
    ͲͷΑ͏ʹॿ͚Δ͔ʁ

    View full-size slide

  26. © Works Applications Co.,Ltd.
    #ccc_f3
    ͳͥSpotBugs͔
    ✤ ࣾ಺ͷਓࡐͱࢿ࢈
    ✤ ಺෦࣮૷ʹ໌Δ͍ෳ਺ͷ։ൃऀ
    ✤ ϓϥάΠϯ࣮૷ܦݧͷ஝ੵ
    ✤ Eclipse࿈ܞ
    ✤ HUE͸EclipseΛඪ४IDEͱ͍ͯ͠Δ
    ✤ Java8αϙʔτ
    ✤ FindBugs 3.0.1͸Lambdaͷѻ͍ʹ

    ໰୊͕͋Δ
    26

    View full-size slide

  27. © Works Applications Co.,Ltd.
    #ccc_f3
    Agenda
    ‣ ࣗݾ঺հ
    ‣ 2017೥5݄ݱࡏͷJava੩తղੳπʔϧػೳɾಈ޲ൺֱ
    ‣ େن໛ERPͷίʔυ඼๊࣭͕͑Δ໰୊ͱͦͷղܾ
    ‣ ։ൃ͍ͯ͠Δ૊৫ͱͦͷ੡඼
    ‣ ߦ͍ͬͯΔ޻෉ͱࠓޙͷల๬
    27

    View full-size slide

  28. © Works Applications Co.,Ltd.
    #ccc_f3
    3. HUE͕ߦ͍ͬͯΔ޻෉ͱ
    ࠓޙͷల๬
    28

    View full-size slide

  29. © Works Applications Co.,Ltd.
    #ccc_f3
    աڈͷࣦഊ
    ✤ σϑΥϧτઃఆͷ··FindBugs΍CheckstyleΛ

    ϩʔΧϧϏϧυ΍ϓϨϚʔδϏϧυʹಋೖ͠ɺ

    ੜ࢈ੑΛେ͖͘Լ͛ͨ
    ✤ ϓϨϚʔδϏϧυ͕1͔͔࣌ؒۙͬͯ͘͠·ͬͨ
    ✤ mvn -Dfindbugs.skip ΍ true

    ͕౰ͨΓલʹͳͬͯ͠·ͬͨ
    29

    View full-size slide

  30. © Works Applications Co.,Ltd.
    #ccc_f3
    աڈͷࣦഊ
    ✤ σϑΥϧτઃఆͷ··FindBugsΛEclipseʹಋೖ͠ɺ

    ੜ࢈ੑΛେ͖͘Լ͛ͨ
    ✤ ϫʔΫεϖʔεʹ10Λ௒͑ΔϓϩδΣΫτΛৗ࣌༻
    ҙͯ͠։ൃ͢Δਓ͕ଟ͔ͬͨ
    ✤ Eclipse PluginʹύϑΥʔϚϯε্ͷ͕ܽؕ͋ͬͨ
    30

    View full-size slide

  31. © Works Applications Co.,Ltd.
    #ccc_f3
    ͦ΋ͦ΋ɺ
    ✤ MSAΛ໨ࢦ͍ͯ͠Δͷʹ૊৫ԣஅͳղੳ͸ඞཁ͔ʁ
    ✤ ֤αʔϏε։ൃऀ͕޷͖ʹ΍Ε͹͍͍ͷͰ͸ʁ
    ✤ ࣏ࣗͰ͖Δ׆ಈΛ։ൃޮ཰Λ௿Լͤͯ͞·Ͱ

    ԣஅతʹ΍Δʁ
    31

    View full-size slide

  32. © Works Applications Co.,Ltd.
    #ccc_f3
    MSAͰ૊৫ԣஅͳղੳ͸ඞཁ͔ʁ
    ✤ ඞཁ
    ✤ ੩తղੳ͸nice to haveͰ͸ͳ͘must to have
    ✤ ͦΕͧΕҟͳΔਓࡐɾ޻਺Λ͍࣋ͬͯΔͷͰ

    ׬શʹ࣏ࣗʹ೚ͤΔͱ͍࣮ͭࢪ͞ΕΔͷ͔ෆ໌ྎ
    ✤ ։ൃޮ཰ΛԼ͛ͳ͍ํ๏Λ୳͢ඞཁ͕͋Δ
    32

    View full-size slide

  33. © Works Applications Co.,Ltd.
    #ccc_f3
    ༏ઌ౓
    ໢ཏੑ
    ʢϝϦοτʣ
    ࣦഊΛ౿·͑ͯ
    ✤ ։ൃޮ཰ʹଥڠ͠ͳ͍
    ✤ ۃྗ։ൃऀͷ೔ৗۀ຿Λ

    ϒϩοΫ͠ͳ͍ख๏Λ୳͢
    ✤ ޮ཰௿ԼΛೲಘͤ͞ΒΕΔ

    Ձ஋Λग़͢
    ✤ ͪΌΜͱத਎Λཧղͯ͠࢖͏
    ✤ ݁ہ͸όονϓϩάϥϜͳͷͰ

    ׳Εͨख๏ͰϓϩϑΝΠϧՄೳ
    ։ൃޮ཰
    ʢೲಘʣ
    33

    View full-size slide

  34. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿͳͥFindBugs͸஗͍ͷ͔ʁ
    ✤ 10਺೥લͷৗࣝʹ΋ͱ͍࣮ͮͨ૷ ʢSpotBugs 3.1.0-RC1Ͱղফʣ
    ✤ MapΛ࢖ͬͨ String#intern() ૬౰ͷࣗલॲཧ
    ✤ ListΠϯελϯεΛ࢖͍·Θͨ͢Ίͷܭࢉॲཧ
    ✤ Eclipse GUIΛසൟʹߋ৽͗͢͠Δ ʢSpotBugs 3.1.0-RC2Ͱղফʣ
    ✤ ղੳର৅͕มΘΔͨͼʹUIΛߋ৽
    ✤ γϯάϧεϨουʢίΞΛ࢖͍੾Εͳ͍ʣ
    34

    View full-size slide

  35. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿ؀ڥมߋͰߴ଎ԽͰ͖Δʁ
    ✤ ΄΅Ͱ͖ͳ͍
    ✤ FindBugs͸CPU bound͕ͩγϯάϧεϨουͳόον
    ✤ ෳ਺ίΞΛ৯͍੾͍ͬͯΔͷ͸JITίϯύΠϥͷεϨου

    ʢ-XX:CICompilerCountͰ૿ݮՄ͕ͩ଎౓ʹ΄΅د༩ͳ͠ʣ
    ✤ OOME΍GC stormΛى͜͞ͳ͍ఔ౓ͷϝϞϦΛ༩͑Ε͹

    ͋ͱ͸CPUίΞ૿΍ͯ͠΋ϝϞϦ૿΍ͯ͠΋มԽͳ͠
    35

    View full-size slide

  36. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿGuava v19.0ղੳͷϚΠΫϩϕϯν
    ʢ4 CPU coresʣ
    36
    128m 256m 512m 1g
    2

    (Default)
    OOME 18.2s 18.0s 18.2s
    3 OOME 19.2s 18.2s 18.0s
    4 OOME 24.8s 24.7s 23.6s
    -XX:CICompilerCount
    -Xmx & -Xms
    refs: https://github.com/spotbugs/spotbugs/pull/128

    View full-size slide

  37. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿGuava v19.0ղੳͷϚΠΫϩϕϯν
    ʢ2 CPU coresʣ
    37
    2g
    Default 26.0s
    G1GC 28.7s
    G1GC
    +
    UseStringDeduplication
    29.1s
    GCઃఆʢJava8ʣ
    -Xmx & -Xms
    refs: https://github.com/spotbugs/spotbugs/pull/128

    View full-size slide

  38. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿઃఆͰfindbugs-maven-pluginΛ
    ߴ଎Խ͢Δʹ͸
    ✤ onlyAnalyzeͰର৅ΫϥεΛ࡟Γɺ

    visitorsͰར༻DetectorΛ࡟Δ͜ͱͰߴ଎ʹͳΔ
    ✤ ൃݟ͍ͨ͠όάʹ༏ઌ౓Λ͚ͭΔ͜ͱ͕؊ཁ
    ✤ ExcludeFilterͰର৅ϑΝΠϧΛ࡟ͬͯ΋଎͘ͳΒͳ͍
    ✤ Filter͸ॲཧͷ݁Ռʹରͯ͠Өڹ͢ΔͨΊ
    38

    View full-size slide

  39. © Works Applications Co.,Ltd.
    #ccc_f3
    ௐࠪɿeffortͷޮՌʢTBUʣ
    39
    ACCUR
    ATE_EX
    CEPTIO
    NS
    MODEL
    _INSTA
    NCEOF
    TRACK
    _GUAR
    ANTEE
    D_VAL
    UE_DER
    EFS_IN_
    NULL_P
    OINTER
    _ANAL
    YSIS
    TRACK
    _VALUE
    _NUMB
    ERS_IN_
    NULL_P
    OINTER
    _ANAL
    YSIS
    INTERP
    ROCED
    URAL_
    ANALY
    SIS
    INTERP
    ROCED
    URAL_
    ANALY
    SIS_OF_
    REFERE
    NCED_
    CLASSE
    S
    CONSE
    RVE_SP
    ACE
    SKIP_
    HUGE
    _MET
    HODS
    min ✓ ✓
    less ✓ ✓ ✓
    default,
    more
    ✓ ✓ ✓ ✓ ✓ ✓
    max ✓ ✓ ✓ ✓ ✓ ✓
    Refs: FindBugs.java

    View full-size slide

  40. © Works Applications Co.,Ltd.
    #ccc_f3
    Ҏ্Λ౿·͑ͯ
    40

    View full-size slide

  41. © Works Applications Co.,Ltd.
    #ccc_f3
    ํ਑
    ✤ ଎౓ॏࢹͷૈ͍ղੳͱɺ໢ཏੑॏࢹͷղੳΛ૊Έ߹Θ
    ͤΔ
    ✤ ϓϨϚʔδϏϧυͰ͸มߋ͞ΕͨΫϥε͚ͩΛղੳ
    ✤ र͍࿙ΕΔ໰୊͸೔࣍ͷղੳͰൃݟɾใࠂ
    41

    View full-size slide

  42. © Works Applications Co.,Ltd.
    #ccc_f3
    ॏ͘໢ཏੑͷߴ͍ղੳʢ֓ཁʣ
    ✤ Jenkins + SonarQubeͰ։ൃ͕׆ൃͰͳ͍࣌ؒଳʹ࣮ࢪ
    ✤ ॏେͰͳ͍Ϩϕϧͷϧʔϧ΋ؚΊ࣮ͯࢪ
    ✤ ։ൃऀ͕͍ͭͰ΋ΞΫηεͰ͖ΔSonarQubeΛఏڙ
    ✤ Readme΍ϓϩδΣΫτҰཡϖʔδʹBadgeΛදࣔ͠

    ҰཡੑͱSonarQube΁ͷಋઢΛ֬อ
    42

    View full-size slide

  43. © Works Applications Co.,Ltd.
    #ccc_f3
    ॏ͘໢ཏੑͷߴ͍ղੳʢ݁Ռʣ
    ✤ 50ͷϓϩδΣΫτ͔Β3,000ͷ໰୊Λݟ͚ͭɺ

    1ϲ݄Ͱ͏ͪ900Λղফͨ͠
    ✤ String.format() ΍ logger.info() ͷϑΥʔϚοτҟৗ
    ✤ ϚϧνεϨουϓϩάϥϛϯάΞϯνύλʔϯ
    43

    View full-size slide

  44. © Works Applications Co.,Ltd.
    #ccc_f3
    ૉૣ͘ૈ͍ղੳʢ֓ཁʣ
    ✤ ॏେͳ໰୊Λத৺ʹௐࠪ
    ✤ ಠࣗMavenϓϥάΠϯͰfindbugs-maven-pluginΛ
    ϥοϓ
    ✤ มߋ͞Εͨ.javaϑΝΠϧҰཡ͔Βߋ৽͞ΕͨՄೳੑ
    ͷ͋ΔclassϑΝΠϧͷҰཡΛSpotBugsʹ౉͢
    44

    View full-size slide

  45. © Works Applications Co.,Ltd.
    #ccc_f3
    ૉૣ͘ૈ͍ղੳʢ݁Ռʣ
    ✤ SpotBugsʹ͔͔Δ࣌ؒΛฏۉ93ˋ࡟ݮ
    ✤ େ͖ͳϦϙδτϦͰ΋1෼Ҏ಺ʹղੳΛऴ͑ΒΕΔ

    ✤ र͍͖Εͳ͍໰୊͸ඞͣग़Δ
    ✤ ྫɿˏNonNullΛΠϯλϑΣʔεʹ௥Ճͨ͠৔߹
    45

    View full-size slide

  46. © Works Applications Co.,Ltd.
    #ccc_f3
    ࠓޙͷల๬
    ✤ ͞Βʹଟ͘ͷϦϙδτϦ΁ͷಋೖ
    ✤ Type AnnotationΛஈ֊తʹಋೖ͢Δ
    ✤ ٕज़ʹͩ͜ΘΓͷڧ͍ɺڞ௨Ϟδϡʔϧ։ൃऀʹ

    ڠྗΛґཔ͢Δ
    46

    View full-size slide

  47. © Works Applications Co.,Ltd.
    #ccc_f3
    4. ࣾ಺FWࢧԉͷͨΊͷ
    SpotBugsϓϥάΠϯ࣮૷ํ๏
    47

    View full-size slide

  48. © Works Applications Co.,Ltd.
    #ccc_f3
    େ·͔ͳྲྀΕ
    ✤ ཁ݅ͷ໌֬Խ
    ✤ ϓϩδΣΫτͷ࡞੒
    ✤ JUnitͰՔಇ֬ೝ͠ͳ͕Β࣮૷
    ✤ Messageͷ࡞੒
    48

    View full-size slide

  49. © Works Applications Co.,Ltd.
    #ccc_f3
    ཁ݅ͷ໌֬Խ
    49
    ✤ ཁ݅ʹԠ֦ͯ͡ு͢΂͖਌Ϋϥε͕มΘΔ
    ✤ OperandStackͷঢ়ଶΛ௥͏ˠOpcodeStackDetector
    ✤ ΞϊςʔγϣϯΛ֬ೝ͢ΔˠAnnotationDetector

    View full-size slide

  50. © Works Applications Co.,Ltd.
    #ccc_f3
    ϓϩδΣΫτͷ࡞੒
    50
    $ mvn archetype:generate \
    -DarchetypeGroupId=com.github.spotbugs \
    -DarchetypeArtifactId=spotbugs-archetype \
    -DarchetypeVersion=0.1.0
    Refs: https://github.com/spotbugs/spotbugs-archetype

    View full-size slide

  51. © Works Applications Co.,Ltd.
    #ccc_f3
    JUnitͰಈ࡞֬ೝ͠ͳ͕Β࣮૷
    51
    ✤ ʮόάͱͯ͠ݟ͚͍ͭͨঢ়ଶʯΛ࣮૷
    ✤ ʮόάͱͯ͠ݟ͔ͭΔ΂͖Ͱͳ͍ঢ়ଶʯΛ࣮૷
    ✤ classϑΝΠϧΛςετ࣮ߦલʹੜ੒

    View full-size slide

  52. © Works Applications Co.,Ltd.
    #ccc_f3 52
    Refs: https://github.com/spotbugs/spotbugs/tree/master/test-harness

    View full-size slide

  53. © Works Applications Co.,Ltd.
    #ccc_f3
    Messageͷ࡞੒
    ✤ src/main/resources/messages.xmlͷվม
    ✤ ʮԿ͕໰୊͔ʯ͚ͩͰͳ͘ʮͲ͏मਖ਼Ͱ͖Δ͔ʯ΋

    ࢦೆ͢Δ͜ͱ͕๬·͍͠
    53
    Refs: http://dl.acm.org/citation.cfm?id=2486877

    View full-size slide

  54. © Works Applications Co.,Ltd.
    #ccc_f3
    Live demo
    54

    View full-size slide

  55. © Works Applications Co.,Ltd.
    #ccc_f3
    5. ·ͱΊ
    55

    View full-size slide

  56. © Works Applications Co.,Ltd.
    #ccc_f3
    େن໛։ൃʹ͓͚Δίʔυ඼࣭վળ
    ✤ ϓϩδΣΫτͷ਺ͱن໛͕େ͖͍MSAͰ͸ӡ༻ͷ

    ೉౓্͕͕Δ
    ✤ ֤αʔϏε։ൃऀ͕੩తղੳπʔϧͷϝϦοτΛ

    ڗडͰ͖Δ؀ڥͷߏங͕ඞཁ
    56

    View full-size slide

  57. © Works Applications Co.,Ltd.
    #ccc_f3
    େن໛։ൃʹ͓͚Δίʔυ඼࣭վળ
    ✤ FindBugs/SpotBugsͷΫηΛཧղ͢Ε͹

    େن໛։ൃͰ΋αΫαΫར༻Ͱ͖Δ
    ✤ ύϥϝʔλͷมߋͰ࣮ߦϧʔϧͱର৅ίʔυΛ

    ߜΓࠐΉɺࠩ෼ղੳͱόον࣮ߦΛ෼͚Δ
    57

    View full-size slide

  58. © Works Applications Co.,Ltd.
    #ccc_f3
    େن໛։ൃʹ͓͚Δίʔυ඼࣭վળ
    ✤ SpotBugsϓϥάΠϯΛ։ൃ͢Ε͹ࣾ಺ϑϨʔϜϫʔΫ
    ݻ༗ͷ໰୊΋੩తղੳπʔϧͰൃݟͰ͖Δ
    ✤ ࣮૷ʹ͸ඞͣ͠΋JVM΍όΠτίʔυͷ஌ࣝ͸ඞཁ
    ͱ͠ͳ͍
    58

    View full-size slide

  59. © Works Applications Co.,Ltd.
    #ccc_f3
    6. ࠾༻৘ใ
    59

    View full-size slide

  60. © Works Applications Co.,Ltd.
    #ccc_f3
    ੈքΛ໨ࢦ͢ΤϯδχΞΛ
    ืू͍ͯ͠·͢
    60

    View full-size slide

  61. © Works Applications Co.,Ltd.
    #ccc_f3
    ۩ମతͳ࿩Λฉ͖͍ͨํ΁
    ✤ ൃදޙʹࢲʹฉ͖ʹདྷ͍ͯͩ͘͞ʂ
    ✤ CIɺMSAɺϚΠάϨʔγϣϯɺ։ൃϓϩηεɺ

    ଟڌ఺։ൃ͸ઐ໳ͳͷͰ৭ʑ͓࿩Ͱ͖·͢.
    61

    View full-size slide

  62. © Works Applications Co.,Ltd.
    #ccc_f3
    Thank you!
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ
    62

    View full-size slide

  63. © Works Applications Co.,Ltd.
    #ccc_f3
    7. ࢀߟࢿྉ
    63

    View full-size slide

  64. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ‣ ιʔείʔυͷ඼࣭޲্ͷͨΊͷޮՌతͰޮ཰తͳ

    ίʔυϨϏϡʔ
    ‣ https://www.slideshare.net/MoriharuOhzu/
    ss-9224836
    64

    View full-size slide

  65. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ‣ ϥϜμࣜ΍ετϦʔϜ API ΍৽͍͠೔࣌ API ͚ͩ
    ͡Όͳ͍ʂ

    Java8 ͷλΠϓɾΞϊςʔγϣϯ͋ͷख͜ͷख
    ‣ http://waman.hatenablog.com/entry/
    2014/05/08/063959
    65

    View full-size slide

  66. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ‣ Type Annotation for Static Program Analysis
    ‣ https://www.slideshare.net/skrb/type-annotation-
    for-static-program-analysis
    66

    View full-size slide

  67. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ✤ G1: from garbage collector to waste management
    consultant
    ✤ https://blogs.oracle.com/java-platform-group/
    g1%3a-from-garbage-collector-to-waste-
    management-consultant
    67

    View full-size slide

  68. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ✤ G1 GC ͓͞Β͍ͱ #jjug_ccc Ͱൃදͨ͠࿩
    ✤ http://cco.hatenablog.jp/entry/
    2015/12/01/011223
    68

    View full-size slide

  69. © Works Applications Co.,Ltd.
    #ccc_f3
    ࢀߟ৘ใ
    ✤ The Google FindBugs fixit
    ✤ http://dl.acm.org/citation.cfm?id=1831738
    69

    View full-size slide