Skip to content

Conversation

ag4ums
Copy link
Contributor

@ag4ums ag4ums commented Sep 26, 2019

Description

Edited global Licenses are not appearing in the Main Licenses section of the readmeoss report

How to test

  • Submit another text/edited text for a license in the License text field
  • select that particular license as a global license
  • generate a readmeoss report

*/
function identifiedGlobalLicenses($contents)
{
foreach ($contents["licensesMain"] as $key1 => $value1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$key1 and $value1 ( and also $key2 and $value2 later) are very generic name and should be replaced

function identifiedGlobalLicenses($contents)
{
foreach ($contents["licensesMain"] as $key1 => $value1) {
$flag = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$flag is a very generic name, and should be replaced by a more descriptive one

* @param[int,out] array $contents
* @return array $contents with identified global license path
*/
function identifiedGlobalLicenses($contents)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$contents is a very generic variable name

}

$contents = array('licensesMain'=>$licenseStmtsMain, 'licenses'=>$licenseStmts, 'copyrights'=>$copyrightStmts, 'licenseAcknowledgements' => $licenseAcknowledgements);
$contents = $this->identifiedGlobalLicenses($contents);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not very readable and it mutates $contents, maybe add a new variable for the result with a descriptive name.

if ($ret !== FALSE) {
$flag = 1;
$mainLicenses[] = $value2;
unset( $contents["licenses"][$key2]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unset( $contents["licenses"][$key2]);
unset($contents["licenses"][$key2]);

* @param[int,out] array $contents
* @return array $contents with identified global license path
*/
function identifiedGlobalLicenses($contents)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is not very descriptive. And I do not understand its functionality from the name or from the description.

foreach ($contents["licensesMain"] as $key1 => $value1) {
$flag = 0;
foreach ($contents["licenses"] as $key2 => $value2) {
$ret = array_search($value1['licenseId'], $value2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ret is a very generic variable name, why not use a descriptive one?

@ag4ums ag4ums force-pushed the fix/readmeoss-global-lic branch from 4fcdb61 to f25b6df Compare October 23, 2019 15:08
@ag4ums ag4ums force-pushed the fix/readmeoss-global-lic branch from f25b6df to 1045cf4 Compare October 24, 2019 11:23
@mcjaeger mcjaeger self-requested a review October 24, 2019 14:27
Copy link
Member

@mcjaeger mcjaeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test works as expected, just adding a global license and it is shown in the report like that

Copy link
Member

@shaheemazmalmmd shaheemazmalmmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good

@mcjaeger mcjaeger merged commit 05f7b2a into fossology:master Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants