Showing 23 of 62 total issues
Function replace
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
[replace](node) {
const con = node.textContent;
const reg = /\{\{(.*?)\}\}/;
// 元素节点
if (node.nodeType === 1) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Preloadimages
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Preloadimages(configs) {
this.total = this.option.resources.length || 0; // 资源总数
this.currentIndex = 0; // 当前加载资源索引
this.option = {
baseUrl: './', // 资源基准url, 默认'./'
Function observe
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
observe(data) {
const dep = new Dep();
for (const key in data) {
if ({}.hasOwnProperty.call(data, key)) {
let val = data[key];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Preloadimages
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function Preloadimages(configs) {
this.total = this.option.resources.length || 0; // 资源总数
this.currentIndex = 0; // 当前加载资源索引
this.option = {
baseUrl: './', // 资源基准url, 默认'./'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function wxShare
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const wxShare = (configs, share = {}) => {
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
// appId: configs.appid, // 必填,公众号的唯一标识
// timestamp: configs.timestamp, // 必填,生成签名的时间戳
Function replace
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
[replace](node) {
const con = node.textContent;
const reg = /\{\{(.*?)\}\}/;
// 元素节点
if (node.nodeType === 1) {
Function jsonp
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function jsonp(opt) {
return new Promise((resolve, reject) => {
let
body = null,
handler = null;
Function parse
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const parse = (dateStr, mask) => {
let isVaild = true;
const dateInfo = {};
const today = new Date();
Function success
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
success() {
/**
* 发送给朋友
*/
wx.onMenuShareAppMessage({
Function viewType
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const viewType = (val) => {
if (val === null) return 'null';
const type = typeof val;
switch (type) {
Function viewType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const viewType = (val) => {
if (val === null) return 'null';
const type = typeof val;
switch (type) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
with open(packageFile + '.less', 'w') as g:
for line in f.readlines():
if not isInArray(mvegarr, line):
g.write(line)
shutil.move(packageFile + '.less', packageFile)
Avoid deeply nested control flow statements. Open
if (eventType && fn) {
node.addEventListener(eventType, fn.bind(this), false);
}
Function constructor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
constructor(configs) {
this.total = this.option.resources.length || 0; // 资源总数
this.currentIndex = 0; // 当前加载资源索引
this.option = {
baseUrl: './', // 资源基准url, 默认'./'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
for line in lines:
s.write(line.replace('npm run webbuild && npm run appbuild', npmdist))
with open(packageFile, 'r') as f:
Avoid deeply nested control flow statements. Open
with open(packageFile + '.less', 'w') as g:
for line in f.readlines():
if not isInArray(mvarr, line):
g.write(line)
shutil.move(packageFile + '.less', packageFile)
Function formatParams
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function formatParams(data) {
const params = [];
if (isObject(data)) {
for (const key in data) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return ctorName(val).toLowerCase();
Avoid too many return
statements within this function. Open
if (isPlainObject(val)) return 'object';