File smartSteps.js
has 393 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* echarts 值轴分段刻度计算方法
*
* @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
Function bothLocked
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bothLocked(min, max, section) {
var trySecs = section ? [section] : custSecs;
var span = max - min;
if (span === 0) { // 最大最小值都锁定到同一个值上,认为锁定失败
max = expNum(max, 3); // 3 位精度向上近似
Function makeResult
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeResult(newMin, newMax, section, expon) {
expon = expon || 0; // 这是中间计算量级,受步长增长、特别是最值锁定的影响,可能会小于基准量级,因为整数部分被过度放大
var expStep = expNum((newMax - newMin) / section, -1);
var expMin = expNum(newMin, -1, 1); // 锁定的最值有效数位可能很多,需要全精度保留
var expMax = expNum(newMax, -1);
Function smartSteps
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function smartSteps(min, max, section, opts) {
// 拿公共变量来接收 opts.steps 这个参数,就不用带着参数层层传递了,注意在函数的最终出口处释放这个值
custOpts = opts || {};
custSteps = custOpts.steps || mySteps;
custSecs = custOpts.secs || mySections;
Function look4sections
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function look4sections(expMin, expMax) {
var section;
var tmpStep, tmpMin, tmpMax;
var reference = [];
for (var i = custSecs.length; i--;) { // 逐步减小段数,步长就会渐大
Function coreCalc
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function coreCalc(min, max, section) {
var step;
var secs = section || +custSecs.slice(-1);
var expStep = getCeil((max - min) / secs, custSteps); // 这是可能的最小步长,以它的量级作为后续计算的基准量级,以保证整数计算特性
var expSpan = expNum(max - min); // 2 位精度的最值跨度,过高的精度意味着有效数位更多
Function tryForInt
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function tryForInt(min, max, section, expMin, expMax, secs) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (emin.e - expMin.e > 6) { // 如果锁定值的量级远小于基准量级,认为锁定失败,强置为 0
expMin = {c: 0, e: emin.e};
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 49.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (emax.e - expMax.e > 6) { // 如果锁定值的量级远小于基准量级,认为锁定失败,强置为 0
expMax = {c: 0, e: emax.e};
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 49.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76