Browse Source

fixup! fixup! [REF] remove use of cloc. use pygount librairy instead

12.0
Sylvain LE GAL 6 years ago
committed by OCA-git-bot
parent
commit
23b2e40c24
  1. 45
      module_analysis/README.rst
  2. 6
      module_analysis/models/base_module_update.py
  3. 10
      module_analysis/models/ir_module_module.py
  4. 2
      module_analysis/post_init_hook.py
  5. 13
      module_analysis/readme/CONFIGURE.rst
  6. 2
      module_analysis/readme/USAGE.rst
  7. BIN
      module_analysis/static/description/config_parameters.png
  8. 2
      module_analysis/views/view_base_module_update.xml
  9. 2
      module_analysis/views/view_ir_module_module.xml

45
module_analysis/README.rst

@ -54,10 +54,9 @@ Each installed modules have extra data in the 'Technical Data' tab :
Installation
============
To use this module, you have to install the application ``cloc``
``sudo apt-get install cloc``
To use this module, you have to install the ``pygount`` python librairy.
``pip install pygount``
Configuration
=============
@ -88,18 +87,54 @@ to update the data, you have to :
This will update analysis of your installed modules.
Adding Extra data
~~~~~~~~~~~~~~~~~
If you want to analyse other data, (for exemple, having the number of HTML
files), create a custom modules and overload the module model :
.. code-block:: python
from odoo import api, fields, models
class IrModuleModule(models.Model):
_inherit = 'ir.module.module'
xml_documentation_qty = fields.Integer(
string='Quantity of Comments in XML Files')
@api.model
def _get_analyse_settings(self):
res = super(IrModuleModule, self)._get_analyse_settings()
if not '.html' in res:
res['.html'] = {}
res['.html']['documentation'] 'xml_documentation_qty'
return res
Exclude files and directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Two parameters are availaible in 'Settings' / 'Technical' / 'Parameters'
'System Parameters' :
.. image:: https://raw.githubusercontent.com/legalsylvain/server-tools/12.0-ADD-module_analysis/module_analysis/static/description/config_parameters.png
The list of folders and filename will be exclude from the analysis.
You can change the default settings.
Usage
=====
* Go to 'Apps' / 'Module Analysis' / 'Installed module by Types'
Open the stats to analyze the detail of the code installed
Open the stats to analyse the detail of the code installed
.. image:: https://raw.githubusercontent.com/legalsylvain/server-tools/12.0-ADD-module_analysis/module_analysis/static/description/analysis_pivot.png
.. image:: https://raw.githubusercontent.com/legalsylvain/server-tools/12.0-ADD-module_analysis/module_analysis/static/description/analysis_pie.png
Bug Tracker
===========

6
module_analysis/models/base_module_update.py

@ -8,11 +8,11 @@ from odoo import api, fields, models
class BaseModuleUpdate(models.TransientModel):
_inherit = 'base.module.update'
analyze_installed_modules = fields.Boolean(
string='Analyze Installed Modules', default=True)
analyse_installed_modules = fields.Boolean(
string='Analyse Installed Modules', default=True)
@api.multi
def update_module(self):
return super(BaseModuleUpdate, self.with_context(
analyze_installed_modules=self.analyze_installed_modules)
analyse_installed_modules=self.analyse_installed_modules)
).update_module()

10
module_analysis/models/ir_module_module.py

@ -84,15 +84,15 @@ class IrModuleModule(models.Model):
@api.model
def update_list(self):
res = super(IrModuleModule, self).update_list()
if self.env.context.get('analyze_installed_modules', False):
self.search([('state', '=', 'installed')]).button_analyze_code()
if self.env.context.get('analyse_installed_modules', False):
self.search([('state', '=', 'installed')]).button_analyse_code()
return res
@api.multi
def write(self, vals):
res = super(IrModuleModule, self).write(vals)
if vals.get('state', False) == 'installed':
self.button_analyze_code()
self.button_analyse_code()
elif vals.get('state', False) == 'uninstalled'\
and 'module_analysis' not in [x.name for x in self]:
self.write(self._get_clean_analyse_values())
@ -100,7 +100,7 @@ class IrModuleModule(models.Model):
# Public Section
@api.multi
def button_analyze_code(self):
def button_analyse_code(self):
IrModuleAuthor = self.env['ir.module.author']
IrModuleTypeRule = self.env['ir.module.type.rule']
rules = IrModuleTypeRule.search([])
@ -112,7 +112,7 @@ class IrModuleModule(models.Model):
exclude_files = [x.strip() for x in val.split(',') if x.strip()]
for module in self:
_logger.info("Analyzing Code for module %s ..." % (module.name))
_logger.info("Analysing Code for module %s ..." % (module.name))
# Update Authors, based on manifest key
authors = []

2
module_analysis/post_init_hook.py

@ -10,4 +10,4 @@ def analyse_installed_modules(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
installed_modules = env['ir.module.module'].search(
[('state', '=', 'installed')])
installed_modules.button_analyze_code()
installed_modules.button_analyse_code()

13
module_analysis/readme/CONFIGURE.rst

@ -28,7 +28,7 @@ This will update analysis of your installed modules.
Adding Extra data
~~~~~~~~~~~~~~~~~
If you want to analyze other data, (for exemple, having the number of HTML
If you want to analyse other data, (for exemple, having the number of HTML
files), create a custom modules and overload the module model :
.. code-block:: python
@ -48,3 +48,14 @@ files), create a custom modules and overload the module model :
res['.html'] = {}
res['.html']['documentation'] 'xml_documentation_qty'
return res
Exclude files and directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Two parameters are availaible in 'Settings' / 'Technical' / 'Parameters'
'System Parameters' :
.. image:: ../static/description/config_parameters.png
The list of folders and filename will be exclude from the analysis.
You can change the default settings.

2
module_analysis/readme/USAGE.rst

@ -1,6 +1,6 @@
* Go to 'Apps' / 'Module Analysis' / 'Installed module by Types'
Open the stats to analyze the detail of the code installed
Open the stats to analyse the detail of the code installed
.. image:: ../static/description/analysis_pivot.png

BIN
module_analysis/static/description/config_parameters.png

After

Width: 1291  |  Height: 63  |  Size: 6.9 KiB

2
module_analysis/views/view_base_module_update.xml

@ -12,7 +12,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="inherit_id" ref="base.view_base_module_update"/>
<field name="arch" type="xml">
<xpath expr='//group[@states="init"]' position="inside">
<field name="analyze_installed_modules"/>
<field name="analyse_installed_modules"/>
</xpath>
</field>
</record>

2
module_analysis/views/view_ir_module_module.xml

@ -12,7 +12,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="inherit_id" ref="base.module_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='state']/.." position="after">
<button name="button_analyze_code" states="installed" string="Refresh Code Analysis" type="object" class="btn btn-primary"/>
<button name="button_analyse_code" states="installed" string="Refresh Code Analysis" type="object" class="btn btn-primary"/>
<group string="Code Size" col="4">
<field name="python_code_qty"/>
<field name="xml_code_qty"/>

Loading…
Cancel
Save