Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Perl::Lint - Yet Another Perl Source Code Linter

2,771 views

Published on

YAPC::Asia 2014
Talking about Perl::Lint

Published in: Technology
  • Be the first to comment

Perl::Lint - Yet Another Perl Source Code Linter

  1. 1. Perl::Lint - Yet Another Perl Source Code Linter http://bit.ly/1p5HdSA @moznion
  2. 2. VOTE ME!
  3. 3. SEE ALSO Perlの静的解析入門と Perlリファクタリングツール App::PRTのご紹介 @hitode909 ! Day 2, 多目的教室3, 16:00
  4. 4. @moznion
  5. 5. @moznion @hitode909
  6. 6. Perl::Lint ! https://github.com/moznion/Perl-Lint   https://metacpan.org/release/MOZNION/Perl- Lint-0.01_01 (<= UNDERDEVELOPMENT!!!)
  7. 7. Perl::Lint ! https://github.com/moznion/Perl-Lint   https://metacpan.org/release/MOZNION/Perl- Lint-0.01_02 (<= UNDERDEVELOPMENT!!!)
  8. 8. What is Perl::Lint?
  9. 9. A. Source Code Linter for Perl
  10. 10. Yes, It’s like… Perl:: http://bit.ly/1l5HrYX
  11. 11. Are you using Perl::Critic? http://bit.ly/1pfMxCW
  12. 12. What is Perl::Critic?
  13. 13. A. Source Code Linter for Perl
  14. 14. Wait!!
  15. 15. What is Source Code Linter???
  16. 16. A. Analyzes the source code and detects the causes of bugs
  17. 17. Search and Destroy http://bit.ly/1AT3Bl3
  18. 18. Concretely…
  19. 19. There are five bad things
  20. 20. There are five bad things
  21. 21. There are five bad things
  22. 22. There are five bad things
  23. 23. There are five bad things
  24. 24. There are five bad things
  25. 25. It was fun?
  26. 26. Is this what I think it is?
  27. 27. It’s just CODE REVIEW?
  28. 28. But do you think human should do the such code review?
  29. 29. Human should work more creative
  30. 30. It seems possible to check by computer
  31. 31. There are five bad things
  32. 32. And probably human overlooks
  33. 33. Hard to Understand Code
  34. 34. Hard to Understand Code Destroy!
  35. 35. Hard to Understand Code Easy to review
  36. 36. Do you like clean code, and why?
  37. 37. Readable code ! ! Reviewable code
  38. 38. Readable code ≒ ! ! Reviewable code
  39. 39. => Maintainable!!
  40. 40. Maintainable code will be growing up along maintainable
  41. 41. Humans can focus on creative work
  42. 42. Okay, Make maintainable code by computer!
  43. 43. And then source code linter was appeared (1979 for C)
  44. 44. Now; js-lint, find-bugs, rubocop, etc…
  45. 45. And language processors: Go, Scala and etc.
  46. 46. Does Perl have?
  47. 47. Perl::Critic is awesome!
  48. 48. Perl::Critic checks the code conform to PBP style or not
  49. 49. Benefit to analyze code by computer
  50. 50. He don’t grumble
  51. 51. He is inexhaustible
  52. 52. He don’t take a mistake
  53. 53. He is fast (in many cases)
  54. 54. And can automation
  55. 55. Cost of human: HIGH ! Cost of computer: LOW
  56. 56. Cost of human: HIGH ! Cost of computer: LOW Good!!
  57. 57. Got it.
  58. 58. But… If there is Perl::Critic, Is Perl::Lint don’t need?
  59. 59. Perl::Critic is awesome but a little slow
  60. 60. In large project, It takes 3 minutes to run only Perl::Critic
  61. 61. How do you spend in meantime?
  62. 62. Coffee? How do you spend in meantime?
  63. 63. Coffee? Chat? How do you spend in meantime?
  64. 64. Coffee? Nap? Chat? How do you spend in meantime?
  65. 65. Coffee? Swing Copters? Nap? Chat? How do you spend in meantime?
  66. 66. Life is too short, so let’s accelerate!!
  67. 67. Rate [num/sec] 100 75 50 25 0 97 18 Perl::Critic Perl::Lint
  68. 68. Rate [num/sec] 100 75 About 50 400% increase 25 0 97 18 Perl::Critic Perl::Lint
  69. 69. Yeah!!!! I'll show you all my tricks
  70. 70. A little break
  71. 71. Background that led to the development
  72. 72. This project receive TPF grant
  73. 73. Do you know TPF grant?
  74. 74. Nozaki-san and Maki-san (@lestrrat-san) are people in a high position of TPF grant
  75. 75. Maki-san「日本人がトップになっ たのに日本から1つもProposal出な いのちょっとアレじゃない?」▼ me「そうですなあ」▼ Maki-san「moznion出してよ」▼ me「!!!!!」▼
  76. 76. Time flies everything goes…
  77. 77. Perl::Lint!!!!
  78. 78. Let’s apply!!!
  79. 79. Return to our subject…
  80. 80. How do we do static analyzing for Perl?
  81. 81. Enough!
  82. 82. Joke :p
  83. 83. Two major methods - Evaluate Token - Evaluate AST
  84. 84. Two major methods - Evaluate Token - Evaluate AST
  85. 85. Tools - PPI - Compiler::Lexer
  86. 86. Tools - PPI - Compiler::Lexer
  87. 87. What is Compiler::Lexer?
  88. 88. *Very Fast* tokenizer made of C++
  89. 89. Compiler::Lexer is fast ⇛ Perl::Lint is fast!
  90. 90. And others: Compiler::Parser, C::CodeGenerator::LLVM, etc… @goccy54++
  91. 91. Example of tokens that is generated by Compiler::Lexer
  92. 92. my $foo;
  93. 93. my $foo;
  94. 94. Points
  95. 95. Use these tokens to analyze
  96. 96. Enough!
  97. 97. Architecture of Perl::Lint
  98. 98. Top Level +args +site_policies +lint +lint_string Policies +evaluate 1 Filters +filter 1 1 .. * 1 .. *
  99. 99. Simple and Easy!
  100. 100. Policies
  101. 101. Each policies are isolated
  102. 102. Easy to make your own policy
  103. 103. Samples
  104. 104. *** CAUTION *** A lot of bad code are here. Close your eyes.
  105. 105. @P::L::P::Miscellanea::ProhibitTies
  106. 106. @P::L::P::Miscellanea::ProhibitTies Check type
  107. 107. @P::L::P::Miscellanea::ProhibitTies Check data
  108. 108. アッ
  109. 109. Feature of Implementation and Bad Know-hows
  110. 110. Use C-Style for()
  111. 111. Use C-Style for() But PBP prohibit it!!
  112. 112. Use List::Util::any instead of grep
  113. 113. Don’t use regex, compare by eq in series
  114. 114. Or use hash …
  115. 115. Function calling is almost gone.
  116. 116. Use simple parts e.g. raw-bless, POPO
  117. 117. Filtering mechanism
  118. 118. Perl::Critic’s default rule system is a bit difficult…
  119. 119. Yes, I know, perlcriticrc can adjust them. But too much hustle
  120. 120. Perl::Lint checks the all of policies as default
  121. 121. And you can filter any policies as you like
  122. 122. Filter by `ignore`
  123. 123. Filter by `filter`
  124. 124. Yes, of course you can deny the all of policies :)
  125. 125. You can define your own filter
  126. 126. e.g.
  127. 127. And Perl::Lint provides default policies
  128. 128. For Perl::Critic users ;)
  129. 129. These are features of Perl::Lint
  130. 130. But installation is such a hassle!
  131. 131. Perl::Lint Playground http://perl-lint.moznion.net
  132. 132. You can try!
  133. 133. Meaning to publish Playground
  134. 134. It makes easy to get feedback
  135. 135. Motivation ➚
  136. 136. Publish the Playground is looking good!
  137. 137. Future works
  138. 138. Implement the all of policies…
  139. 139. ## no lint
  140. 140. Module for testing (Like a Test::Perl::Critic)
  141. 141. Cooperate with GitHub (Like a Coveralls)
  142. 142. Inject the result into code as TODO comment (inspired by rubocop)
  143. 143. As you see, Perl::Lint is under development
  144. 144. SEGV, ABRT, etc…
  145. 145. I’m looking for contributors!
  146. 146. DEMO
  147. 147. Any Questions?

×