Glavin001 / tslint-clean-code

TSLint rules for enforcing Clean Code
https://www.npmjs.com/package/tslint-clean-code
MIT License
169 stars 15 forks source link

I get too little cohesion error from a single method that multiplies #59

Closed ali-habibzadeh closed 4 years ago

ali-habibzadeh commented 6 years ago

Is it expected for the class below to be picked up for too little cohesion?

class Multiplier {
  multiply(item: number) {
    return item * 2;
  }
}

[tslint] The cohesion of this class is too low. Consider splitting this class into multiple cohesive classes: Multiplier (min-class-cohesion)

What splitting is suggested here?

Glavin001 commented 6 years ago

This may be a bug. The min-class-cohesion is not something I personally use as it is not perfected yet.

Implementation can be found at https://github.com/Glavin001/tslint-clean-code/blob/master/src/minClassCohesionRule.ts and tests at https://github.com/Glavin001/tslint-clean-code/blob/master/src/tests/MinClassCohesionRuleTests.ts

Pull Requests welcome! Adding a failing test to https://github.com/Glavin001/tslint-clean-code/blob/master/src/tests/MinClassCohesionRuleTests.ts would be a great place to start.

ali-habibzadeh commented 6 years ago

Ok. Will reopen this. After our current project, I will try to make a PR for this. @balvienie Adding you in so we both remember.