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

静的解析の育て方 / How to make your static analysis strong

Yuichi Sugiyama
February 10, 2020
2.7k

静的解析の育て方 / How to make your static analysis strong

Yuichi Sugiyama

February 10, 2020
Tweet

More Decks by Yuichi Sugiyama

Transcript

  1. • Phanͷ࣮ߦ݁Ռ͔Βੜ੒Ͱ͖Δ suppress_issue_types $cat analysis.txt | cut -f 2 -d

    ' '|\ sort -u | sed "s/^/'/g" | sed "s/$/',/g" $*͕ಋೖͰ͖ͨʂ
  2. • Phanͷ࣮ߦ݁Ռ͔Βੜ੒Ͱ͖Δ suppress_issue_types $cat analysis.txt | cut -f 2 -d

    ' '|\ sort -u | sed "s/^/'/g" | sed "s/$/',/g" ͕ɺ΄΅Τϥʔใࠂ͸͞Εͳ͍ɻɻɻ
  3. • Phanͷ࣮ߦ݁Ռ͔Βੜ੒Ͱ͖Δ suppress_issue_types $cat analysis.txt | cut -f 2 -d

    ' '|\ sort -u | sed "s/^/'/g" | sed "s/$/',/g" ͔͜͜Β੩తղੳΛҭͯΑ͏ʂ
  4. PhpStormͷ৔߹: Inspect Code • PhpStorm https://www.jetbrains.com/ja-jp/phpstorm/ • ΈΜͳେ޷͖PHPͷIDE • ϓϩδΣΫτ಺ͷҟৗίʔυΛ


    ϑΝΠϧΛ։͚ͩ͘Ͱݕग़ͯ͘͠ΕΔʂ • ϓϩδΣΫτશମͷInspectionϨϙʔτΛ
 ग़ྗͰ͖Δ 
  5. Inspect Code • Find Action (Ctrl + Shift + A,

    ⌘+⇧+A )ʹ
 “Inspect”ͱೖΕͯΈΔ 
  6. ਺ͷଟ͍Issue Type • 1ߦमਖ਼͢Δ͚ͩͰɺ਺ඦͷIssueΛ
 ফ͢͜ͱ͕Ͱ͖Δ৔߹΋͋Δ • PHPDoc͕͓͔͍͠ͱ͔  /** *

    @return Barɺ઀ଓʹࣦഊͨ͠৔߹͸false */ public function foo() { ɹ… } ϊΠζʹͳΔͷͰαΫοͱ௚ͦ͏
  7. PhpStormͷAuto fix • ͲͷInspectionʹAuto fix͕͋Δ͔͸
 ࣮ࡍʹ΍ͬͯΈΔ͔͠ͳͦ͞͏ • ΋ͷʹΑͬͯ͸Auto fixͰ΋յΕΔ͜ͱ͕͋ΔͷͰ৻ॏ •

    Auto fix͕෇͍͍ͯΔ͜ͱ͕ଟ͍ͷ͸ɺ • Unnecessary ~ܥͷInspection • Code StyleܥͷInspection • Missing ~ ܥͷPHPDocͷInspection