Showing 75 of 579 total issues
Method parse
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parse(array $data)
{
$schemaId = SchemaId::fromString($data['id']);
$parameters = [
Function fromFile
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function fromFile($file)
{
if (!array_key_exists($file, $this->files)) {
$xmlData = $this->getXmlData($file);
- 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 getFieldDescriptor
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getFieldDescriptor(SchemaId $schemaId, array $field)
{
// force default type to be "string"
if (!isset($field['type'])) {
$field['type'] = 'string';
Method loadFile
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function loadFile($file, $schemaOrCallable = null)
{
$content = @file_get_contents($file);
if ('' === trim($content)) {
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
Method generateMessage
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateMessage(SchemaDescriptor $schema, GeneratorResponse $response)
{
$className = $this->schemaToClassName($schema, true);
$psr = $this->schemaToNativeNamespace($schema);
$file = str_replace('\\', '/', "{$psr}\\{$className}");
Method generateMessage
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function generateMessage(SchemaDescriptor $schema, GeneratorResponse $response)
{
$id = $schema->getId();
$className = $this->schemaToClassName($schema, true);
$file = "{$id->getVendor()}/{$id->getPackage()}";
Method getSchemas
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSchemas()
{
return [
[
'data' => __DIR__ . '/Fixtures/json-schema/article.json',
Method convertDomElementToArray
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertDomElementToArray(\DomElement $element, $checkPrefix = true)
{
$prefix = (string)$element->prefix;
$empty = true;
$config = [];
Method execute
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$file = $input->getOption('config') ?: sprintf('%s/pbjc.yml', getcwd());
Method fromFile
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fromFile($file)
{
/** @var \DOMDocument $xmlDomDocument */
if (!$xmlDomDocument = XmlUtils::loadFile($file, __DIR__ . '/../xsd/enums.xsd')) {
throw new \RuntimeException(sprintf(
Function getFieldDescriptor
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function getFieldDescriptor(SchemaId $schemaId, array $field)
{
// force default type to be "string"
if (!isset($field['type'])) {
$field['type'] = 'string';
- 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 __construct
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($id, array $parameters = [])
{
$this->id = $id instanceof SchemaId ? $id : SchemaId::fromString($id);
foreach ($parameters as $key => $value) {
- 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 run
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run($language, CompileOptions $options)
{
$namespaces = $options->getNamespaces();
if (!$namespaces || count($namespaces) === 0) {
Method setUp
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setUp()
{
SchemaStore::addSchema(
SchemaId::fromString('pbj:vendor2:package2:category2:message2:1-0-0'),
new SchemaDescriptor(
Method validate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
{
$fa = array_merge($a->getInheritedFields(), $a->getFields());
$fb = array_merge($b->getInheritedFields(), $b->getFields());
Method render
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function render($template, array $parameters)
{
return str_replace(
[
' ',
Function fromFile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function fromFile($file)
{
/** @var \DOMDocument $xmlDomDocument */
if (!$xmlDomDocument = XmlUtils::loadFile($file, __DIR__ . '/../xsd/enums.xsd')) {
throw new \RuntimeException(sprintf(
- 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 updateFieldOptions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function updateFieldOptions(SchemaDescriptor $schema, FieldDescriptor $field)
{
if ($enum = $field->getEnum()) {
if (null === $field->getLanguage(static::LANGUAGE)->get('default', null)) {
$default = $field->getDefault();
- 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 updateFieldOptions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function updateFieldOptions(SchemaDescriptor $schema, FieldDescriptor $field)
{
if ($enum = $field->getEnum()) {
if (null === $field->getLanguage(static::LANGUAGE)->get('default', null)) {
$default = $field->getDefault();
- 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 extractImportsFromFields
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function extractImportsFromFields(array $fields)
{
$imports = [];
foreach ($fields as $field) {