{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Cohesion\n\n[![Build Status](https://travis-ci.org/mschwager/cohesion.svg?branch=master)](https://travis-ci.org/mschwager/cohesion)\n[![Build Status](https://ci.appveyor.com/api/projects/status/github/mschwager/cohesion?branch=master&svg=true)](https://ci.appveyor.com/project/mschwager/cohesion/branch/master)\n[![Coverage Status](https://coveralls.io/repos/github/mschwager/cohesion/badge.svg?branch=master)](https://coveralls.io/github/mschwager/cohesion?branch=master)\n[![Python Versions](https://img.shields.io/pypi/pyversions/cohesion.svg)](https://img.shields.io/pypi/pyversions/cohesion.svg)\n[![PyPI Version](https://img.shields.io/pypi/v/cohesion.svg)](https://img.shields.io/pypi/v/cohesion.svg)\n\nCohesion is a tool for measuring Python class cohesion.\n\n> In computer programming, cohesion refers to the degree to which the elements\n> of a module belong together. Thus, cohesion measures the strength of\n> relationship between pieces of functionality within a given module. For\n> example, in highly cohesive systems functionality is strongly related.\n> - [Wikipedia](https://en.wikipedia.org/wiki/Cohesion_(computer_science))\n\n> When cohesion is high, it means that the methods and variables of the class\n> are co-dependent and hang together as a logical whole.\n> - Clean Code pg. 140\n\nSome of the advantages of high cohesion, also by Wikipedia:\n\n* Reduced module complexity (they are simpler, having fewer operations).\n* Increased system maintainability, because logical changes in the domain\n affect fewer modules, and because changes in one module require fewer\n changes in other modules.\n* Increased module reusability, because application developers will find\n the component they need more easily among the cohesive set of operations\n provided by the module.\n\n# Installing\n\n```\n$ python -m pip install cohesion\n$ cohesion -h\n```\n\nOR\n\n```\n$ git clone https://github.com/mschwager/cohesion.git\n$ cd cohesion\n$ PYTHONPATH=lib/ python -m cohesion -h\n```\n\n# Using\n\nCohesion measures class and instance variable usage across the methods\nof that class.\n\n```\n$ cat example.py\nclass ExampleClass1(object):\n class_variable1 = 5\n class_variable2 = 6\n\n def func1(self):\n self.instance_variable = 6\n\n def inner_func(b):\n return b + 5\n\n local_variable = self.class_variable1\n\n return local_variable\n\n def func2(self):\n print(self.class_variable2)\n\n @staticmethod\n def func3(variable):\n return variable + 7\n\nclass ExampleClass2(object):\n def func1(self):\n self.instance_variable1 = 7\n```\n\n```\n$ cohesion --files example.py --verbose\nFile: example.py\n Class: ExampleClass1 (1:0)\n Function: func1 2/3 66.67%\n Variable: class_variable1 True\n Variable: class_variable2 False\n Variable: instance_variable True\n Function: func2 1/3 33.33%\n Variable: class_variable1 False\n Variable: class_variable2 True\n Variable: instance_variable False\n Function: func3 0/3 0.00%\n Variable: class_variable1 False\n Variable: class_variable2 False\n Variable: instance_variable False\n Total: 33.33%\n Class: ExampleClass2 (23:0)\n Function: func1 1/1 100.00%\n Variable: instance_variable1 True\n Total: 100.00%\n```\n\nThe `--below` and `--above` flags can be specified to only show classes with\na cohesion value below or above the specified percentage, respectively.\n\n## Flake8 Support\n\nCohesion supports being run by `flake8`. First, ensure your installation has\nregistered `cohesion`:\n\n```\n$ flake8 --version\n3.2.1 (pyflakes: 1.0.0, cohesion: 0.8.0, pycodestyle: 2.2.0, mccabe: 0.5.3) CPython 2.7.12 on Linux\n```\n\nAnd now use `flake8` to lint your file:\n\n```\n$ flake8 example.py\nexample.py:1:1: H601 class has low cohesion\n```\n\n## Python Versions\n\nIf you would like to simultaneously run Cohesion on Python 2 and Python 3\ncode then you will have to install it for both versions. I.e.\n\n```\n$ python2 -m pip install cohesion\n$ python3 -m pip install cohesion\n```\n\nThen use the corresponding version to run the module:\n\n```\n$ python2 -m cohesion --files python2_file.py\n$ python3 -m cohesion --files python3_file.py\n```\n\n# Developing\n\nFirst, install development packages:\n\n```\n$ python -m pip install -r requirements-dev.txt\n```\n\n## Testing\n\n```\n$ nose2\n```\n\n## Linting\n\n```\n$ flake8\n```\n\n## Coverage\n\n```\n$ nose2 --with-coverage\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mschwager/cohesion", "keywords": "", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "cohesion", "package_url": "https://pypi.org/project/cohesion/", "platform": "", "project_url": "https://pypi.org/project/cohesion/", "project_urls": { "Homepage": "https://github.com/mschwager/cohesion" }, "release_url": "https://pypi.org/project/cohesion/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "A tool for measuring Python class cohesion.", "version": "1.0.0" }, "last_serial": 5512858, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "f735e4fa689b77313edb46c6434e7df5", "sha256": "a0d5625fe6c0803a6d343150d03d35f021551b49ee127a4c3684411f6ab06755" }, "downloads": -1, "filename": "cohesion-0.5.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "f735e4fa689b77313edb46c6434e7df5", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 5117, "upload_time": "2016-08-16T20:27:12", "url": "https://files.pythonhosted.org/packages/9d/56/536846a677d672f6176eccbc66d4da05101960ef755e865d36df3a3fbc25/cohesion-0.5.0-py2.py3-none-any.whl" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "0b5fc31e76753afb20c7e320318295a5", "sha256": "418429099d9fe5627d5889db6534fb69649e0ce3dbdf1d15e698059fe88ef0ba" }, "downloads": -1, "filename": "cohesion-0.5.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "0b5fc31e76753afb20c7e320318295a5", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 5138, "upload_time": "2016-08-16T21:11:10", "url": "https://files.pythonhosted.org/packages/e1/db/2b29b55958681a994a52a06767465426cf1952ea9218a73f9c00926694c3/cohesion-0.5.1-py2.py3-none-any.whl" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "84f571ae6044aec8cd4585a7d4c4b9da", "sha256": "9c697780f7ee61555709dcf23b0a3a928918c24e871664bf740bbe4469db86bb" }, "downloads": -1, "filename": "cohesion-0.6.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "84f571ae6044aec8cd4585a7d4c4b9da", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 5750, "upload_time": "2016-08-27T18:41:21", "url": "https://files.pythonhosted.org/packages/4f/1f/e346e03209ea42ea1d29c0aaa9260cf8c36b7cd7cb254fce4396d1fc6df0/cohesion-0.6.0-py2.py3-none-any.whl" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "2ca1bcc8a04a4f3bb59445001a1ba8fe", "sha256": "8a93e01fb519c6cf55a8640db3d9bd9ee722acaa5b7ddc2862a52db6dd93e617" }, "downloads": -1, "filename": "cohesion-0.6.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "2ca1bcc8a04a4f3bb59445001a1ba8fe", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 5908, "upload_time": "2016-09-22T02:02:27", "url": "https://files.pythonhosted.org/packages/c7/de/ae2b45039e366ae237bb29e7ee5779d994cd8f66d07f0ab07d6f7691a729/cohesion-0.6.1-py2.py3-none-any.whl" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "c2a6563d659df41132b89b6d2bd6c9fe", "sha256": "f96917ddf2d0f508916b6b9e25a38847cf0218c7a00c431f006b4976df6e5c78" }, "downloads": -1, "filename": "cohesion-0.7.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "c2a6563d659df41132b89b6d2bd6c9fe", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 5936, "upload_time": "2017-06-15T20:49:23", "url": "https://files.pythonhosted.org/packages/c3/0b/9e6f3f9efd0649bd8612a911a89a18b5b2f07b85805c11f26c79b6ab64cb/cohesion-0.7.0-py2.py3-none-any.whl" } ], "0.8.0": [ { "comment_text": "", "digests": { "md5": "0fc2cd5cce1de6a4e1fa886a0f46169e", "sha256": "ea3d5fb098c94281bc42727007fdf9e67b462e1cadaaa365b394f0a6723e7b32" }, "downloads": -1, "filename": "cohesion-0.8.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "0fc2cd5cce1de6a4e1fa886a0f46169e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7959, "upload_time": "2017-10-01T23:14:58", "url": "https://files.pythonhosted.org/packages/0b/6b/381d0fb7fa90c54e722d654176b2fe16aa16167e7159b27c088d0a715518/cohesion-0.8.0-py2.py3-none-any.whl" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "47f8bc886f6129cadf90ed8677805dfb", "sha256": "fe6e837e80830032088d59626cb8ef95cb966f6ae686cea567b235c014780ae7" }, "downloads": -1, "filename": "cohesion-0.9.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "47f8bc886f6129cadf90ed8677805dfb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8632, "upload_time": "2018-09-20T22:35:32", "url": "https://files.pythonhosted.org/packages/6f/e9/5950fa60c45e50852e7b3fc185a0fe63290529e535b794c88817a1c6f69d/cohesion-0.9.0-py2.py3-none-any.whl" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "9b7ec8f6abf12ca4de919d9406c9f261", "sha256": "a20019bdf6c5345bb1ddf18124121b87b79db5a039f20b53547d9e664dab19ed" }, "downloads": -1, "filename": "cohesion-0.9.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "9b7ec8f6abf12ca4de919d9406c9f261", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8647, "upload_time": "2018-09-20T22:45:47", "url": "https://files.pythonhosted.org/packages/67/f2/cf09448fa0186a7661fd37e0f1bc3e35d1e5d6d403e6dca306c6ac5b1266/cohesion-0.9.1-py2.py3-none-any.whl" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "fcef27019fbd1f584e2dbb9da0e2ad66", "sha256": "a33a526eb8922c7dbfef19257b3532d16e6246c4ece3ab3b492b290d9d3f2d4b" }, "downloads": -1, "filename": "cohesion-1.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "fcef27019fbd1f584e2dbb9da0e2ad66", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20884, "upload_time": "2019-07-10T16:08:05", "url": "https://files.pythonhosted.org/packages/c9/f3/e0ad88cb326e261d759e8f5a2d04239850c59500ac81f1b5e5d17d116f18/cohesion-1.0.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fcef27019fbd1f584e2dbb9da0e2ad66", "sha256": "a33a526eb8922c7dbfef19257b3532d16e6246c4ece3ab3b492b290d9d3f2d4b" }, "downloads": -1, "filename": "cohesion-1.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "fcef27019fbd1f584e2dbb9da0e2ad66", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20884, "upload_time": "2019-07-10T16:08:05", "url": "https://files.pythonhosted.org/packages/c9/f3/e0ad88cb326e261d759e8f5a2d04239850c59500ac81f1b5e5d17d116f18/cohesion-1.0.0-py2.py3-none-any.whl" } ] }