Showing 9,449 of 9,537 total issues
Function BrandTag
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const BrandTag = () => {
const [showBranding, setShowBranding] = useState(false);
useEffect(() => {
checkEntitlement({ setShowBranding });
}, []);
Function reducer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
function reducer(state, action) {
switch (action.type) {
case 'increment':
return {
...state,
Function hasValues
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const hasValues = (val) => {
switch (type.typeOf(val)) {
case 'boolean':
case 'date':
case 'function':
Function build
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function build(options) {
const context = createContext(options);
const components = await buildRefs({ context });
testSchema({ components, context });
buildApp({ components, context });
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
return;
}
- 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 58.
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
Identical blocks of code found in 2 locations. Consider refactoring. Confirmed
if (!type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
return;
}
- 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 58.
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
Function fetch
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
async fetch(request) {
request.loading = true;
const startTime = Date.now();
try {
Function wrappedHandler
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function wrappedHandler(req, res) {
const context = {
// Important to give absolute path so Next can trace build files
rid: crypto.randomUUID(),
buildDirectory: path.join(process.cwd(), 'build'),
Function wrappedHandler
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function wrappedHandler(req, res) {
const context = {
// Important to give absolute path so Next can trace build files
rid: crypto.randomUUID(),
buildDirectory: path.join(process.cwd(), 'build'),
Function PaginationBlock
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const PaginationBlock = ({ blockId, loading, methods, properties, value }) => {
const [state, setState] = useState(() =>
calculateState({
defaultCurrent: 1,
defaultPageSize: properties.pageSizeOptions?.[0] ?? 10,
- 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 _regex
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Confirmed
function _regex({ location, params, state }) {
const pattern = type.isObject(params) ? params.pattern : params;
if (!type.isString(pattern)) {
throw new Error(
`Operator Error: _regex.pattern must be a string. Received: ${JSON.stringify(
- 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 _random
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Confirmed
function _random({ location, params }) {
if (!type.isString(params) && !type.isObject(params)) {
throw new Error(
`Operator Error: _random takes an string or object type. Received: ${JSON.stringify(
params
- 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 MultipleSelector
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const MultipleSelector = ({
blockId,
components: { Icon },
events,
loading,
- 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 _nunjucks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function _nunjucks({ location, params, state, payload, runtime }) {
let templateString;
let on;
if (type.isObject(params) && type.isString(params.template)) {
templateString = params.template;
- 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 dateFilter
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const dateFilter = (date, format, ...args) => {
// for no date, return undefined.
if (type.isNone(date)) {
return '';
}
- 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 validateVersion
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async function validateVersion({ cliVersion, lowdefyVersion, print, requiresLowdefyYaml }) {
if (!requiresLowdefyYaml) {
return;
}
if (lowdefyVersion === 'local') {
- 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 apiWrapper
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function apiWrapper(handler) {
return async function wrappedHandler(req, res) {
const context = {
// Important to give absolute path so Next can trace build files
rid: crypto.randomUUID(),
Function provideDocumentLinks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async provideDocumentLinks(
document: vscode.TextDocument,
token: vscode.CancellationToken
): Promise<vscode.DocumentLink[] | undefined> {
let links: vscode.DocumentLink[] = [];
Function constructor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
constructor({ arrayIndices = [], areas, context }) {
this.id = Math.random()
.toString(36)
.replace(/[^a-z]+/g, '')
.substring(0, 5);
Consider simplifying this complex logical expression. Confirmed
if (type.isObject(item)) {
let path = `${key}.${nextKey}[${index}]`;
// TODO: Convert all artifacts to not modify id.
const id =
item.blockId ??