File yf_core_api.class.php
has 604 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Core API.
*/
yf_core_api
has 59 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_core_api
{
public $section_paths = [
'core' => 'classes/',
'user' => 'modules/',
Function get_github_link
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function get_github_link($input, $section = 'all')
{
$is_module = false;
$is_func = false;
if (is_array($input)) {
- 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 get_submodules
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function get_submodules($section = 'all')
{
$data = [];
foreach ($this->section_paths as $_section => $folder) {
if ($section != 'all' && $section != $_section) {
- 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 get_plugins
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function get_plugins()
{
$folder = '';
$suffix = '/';
$libs = [];
- 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
Method get_github_link
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_github_link($input, $section = 'all')
{
$is_module = false;
$is_func = false;
if (is_array($input)) {
Function get_all_hooks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_all_hooks($section = 'all', $hooks_prefix = '_hook_')
{
$hooks_pl = strlen($hooks_prefix);
$hooks = [];
foreach ((array) $this->get_private_methods($section) as $module => $methods) {
- 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
Method show_docs
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show_docs(array $info)
{
$tests = '';
if ($info['is_func']) {
$tests = _class('core_api')->get_function_tests($info['name']);
Function get_method_source
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function get_method_source($module, $method, $section = 'all')
{
if ( ! is_object($module)) {
if (false !== strpos($module, '/')) {
list($subfolder, $module) = explode('/', $module);
- 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 get_libs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function get_libs($folder = 'vendor/')
{
$libs = [];
$suffix = '/';
foreach ($this->get_globs($folder, $suffix) as $glob) {
- 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 get_properties
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_properties($section = 'all')
{
$props = [];
foreach ((array) $this->get_classes($section) as $_section => $modules) {
foreach ((array) $modules as $module) {
- 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 get_widgets
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_widgets($section = 'all', $prefix = 'widget__')
{
$prefix_len = strlen($prefix);
$data = [];
foreach ((array) $this->get_all_hooks($section) as $module => $_hooks) {
- 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 get_methods
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_methods($section = 'all')
{
$methods = [];
foreach ((array) $this->get_classes($section) as $_section => $modules) {
foreach ((array) $modules as $module) {
- 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 get_classes_by_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_classes_by_params($extra = [], &$paths = [])
{
$prefix = isset($extra['prefix']) ? $extra['prefix'] : YF_PREFIX;
$suffix = isset($extra['suffix']) ? $extra['suffix'] : YF_CLS_EXT;
$folder = isset($extra['folder']) ? $extra['folder'] : $this->section_paths['core'];
- 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 get_hooks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_hooks($hook_name, $section = 'all')
{
$hooks = [];
foreach ((array) $this->get_all_hooks($section) as $module => $_hooks) {
foreach ((array) $_hooks as $name => $method_name) {
- 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 get_public_methods
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_public_methods($section = 'all')
{
$data = [];
foreach ((array) $this->get_methods($section) as $module => $methods) {
foreach ((array) $methods as $method) {
- 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 get_private_methods
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_private_methods($section = 'all')
{
$data = [];
foreach ((array) $this->get_methods($section) as $module => $methods) {
foreach ((array) $methods as $method) {
- 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 show_docs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function show_docs(array $info)
{
$tests = '';
if ($info['is_func']) {
$tests = _class('core_api')->get_function_tests($info['name']);
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function get_function_docs($name)
{
$docs_dir = YF_PATH . '.dev/docs/en/';
$f = $docs_dir . $name . '.stpl';
if (file_exists($f)) {
- 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 93.
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
public function get_module_docs($name)
{
$docs_dir = YF_PATH . '.dev/docs/en/';
$f = $docs_dir . $name . '.stpl';
if (file_exists($f)) {
- 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 93.
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