Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code metrics of php - Notepad++

In particular, I am interested to know how many lines of codes there are, but this spans across many files.

I have been using notepad++ to author the code and for each file it does display line numbers but of course I have empty returns to make the code more readable.

Does anyone know of a plugin or tool that I can accurately get the actual lines of code?

like image 659
Harry Avatar asked Jun 24 '10 11:06

Harry


3 Answers

  1. Go to Search -> Find in Files... or use Ctrl+Shift+F

    http://i.stack.imgur.com/V5MKW.png

  2. Find what: \S+\s*\r\n

    Filters: *.php

    Search Mode Regular expression

    Click Find All

    http://i.stack.imgur.com/YRXUX.png

  3. See the 'Find result' in the lower pane

    i.stack.imgur.com/UpuAQ.png

It's not perfect at all, but it works out of the box. Of course you can also make changes to the regular expression, like only counting lines with:

  • White space only: ^\s*\r\n
  • At least one letter or number: \w+.*\r\n
  • Which are used solely for curly braces: ^(\s*[{}]\s*)+\r\n
  • A class keyword: class .*\r\n
  • A function keyword: function .*\r\n
like image 153
bwb Avatar answered Oct 23 '22 20:10

bwb


Google for "php sloc counter". There are plenty of tools to do that, for example:

http://thecodecentral.com/2007/12/26/source-line-of-code-counter

However, this kind of measuring is absolutely useless, so I'm not sure why you would want to do this.

like image 45
houbysoft Avatar answered Oct 23 '22 20:10

houbysoft


Linux:

find -name '*.php' | xargs grep -av '\r' | wc -l

Windows (PowerShell):

(dir -include *.php -recurse | select-string "(?!^$)").count
like image 42
silent Avatar answered Oct 23 '22 18:10

silent